How do I get a native angularjs state change for an anchor link that has been $compile()'d?
Updates: 2018-06-18 - Still hitting this problem. Been searching like crazy trying different things and still nothing; 2018-05-28 - I'm still having this issue and don't really have any leads. I've tried many variations and the problem of dynamically linking text with native angularjs state changes remains.
I have some untrusted text which I pass through a service that links #hashtags and @mentiontags. I use $sce.trustAsHtml() and I assign the linkified text back to a $scope.text variable which I use in the view. It works, I can see and click on the link, but instead of a state change I'm getting a full browser url load.
I've checked the state change when done normally through a view and it works.
So, for example:
- I have some untrusted text:
Hey, @user, you'll love this!
- I pass it through the linking function and get this:
Hey, <a ui-sref="user">@user</a>, you'll love this!"
- I $compile() that to get states linked up and when inspected in the DOM, it looks like this:
Hey, <a ui-sref="user" href="/user">@user</a>, you'll love this!
But when I click the link it's not an angularjs state change, it's a full browser url reload.
Any ideas?
Thanks,