Created
November 18, 2015 09:58
-
-
Save dhoko/1c1f74624dd8df8b08a5 to your computer and use it in GitHub Desktop.
handle anchor hash linking in AngularJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @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