Skip to content

Instantly share code, notes, and snippets.

@dhoko
Created November 18, 2015 09:58
Show Gist options
  • Select an option

  • Save dhoko/1c1f74624dd8df8b08a5 to your computer and use it in GitHub Desktop.

Select an option

Save dhoko/1c1f74624dd8df8b08a5 to your computer and use it in GitHub Desktop.
handle anchor hash linking in AngularJS
/**
* @param String content Html
* @param String state State url -> $state.$current.url
*/
const bindAnchor = (content, state) => {
return content
.replace(/href="#\w+"/g, match => {
const url = match.split('#');
return `${url[0]}#${state}#${url[1]}`;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment