c# - Angular js Replace html string with Tokens -


i have value coming model relatively huge html string. has token needs replaced value angular. trying see how both of ends meet.

my html

<h2 class="sub-title"> @model.welcometext </h2> 

now welcome text relatively html string has token.

 "hi @@name , welcome our website. click <a href='#'> here </a>  more details. <small> more details please visit blah blah  </small> 

now need replace @@name model value in controller- $scope.name

i tried

<h2 class="sub-title" ng-init= $scope.welcometext('@model.welcometext') </h2> 

and in controller

function welcometext(str) {   return str.replace('@@name',$scope.name); } 

but breaks in html because of $scope.welcometext has invalid values inside ng-init

any pointers on how achieve this? model.title sitecore cms. dont have value in js

i ended doing this. not sure if ideal solution atleast works.

    //added div hidden class value.           <div class="hidden" id="inp-title-server" /> @model.title  </div>     <h2 class="sub-title" data-ng-bind-html="$scope.header"></h2> 

then in controller,

var title = $("#inp-title-server").text(); $scope.header = title.replace('@@name', $scope.name); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -