0

I have an C# MVC tag helper, which generates menu items for me. However I want these URLs to be dynamic based on a value set by angular. So my backend generates a URL like this:

 /blah/blah/{{vm.value}}

If I have an angular controller which has a property of value, will the link be updated everytime the value changes. It's not working for me. angular seems to be ignoring the {{vm.value}} because it was generated on the backend and is not in my template.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
Bill Posters
  • 1,079
  • 2
  • 12
  • 16
  • It sounds like you might not be using the "controllerAs: 'vm'" bit inside of your router, but some code would help in solving this. – Mathew Kleppin Aug 21 '15 at 06:41

1 Answers1

0

In-controller:-

$scope.linkValue = "<a ng-href="/blah/blah/{{vm.value}}">Test</a>";

In-html:-

<div ng-bind-html="linkValue | sanitize"></div>

In-filter:-

app.filter("sanitize", ['$sce', function($sce) {
  return function(htmlCode){
    return $sce.trustAsHtml(htmlCode);
  }
}]);

Check this post

Community
  • 1
  • 1