Gobinath M
Gobinath M

Reputation: 2021

How to change the Link path specified text using Angular JS

We have a JSON data provides below link.

https://www-quicker.cna.com/profiles/html/profileView.do?userid=qui9090

But we need to change the link as we mention below,

https://www-quicker.cna.com/profiles/photo.do?userid=qui9090

I need to change "/html/profileView.do?" insead of "/photo.do?"

We try with filters i cant find any good method.

HTML :

 <div ng-repeat="x in todos.records">
 <p>
   {{(x.Name === '/photo.do?') ? '/html/profileView.do?' : x.Name}}
  </p>
  </div>

Upvotes: 0

Views: 54

Answers (1)

theblindprophet
theblindprophet

Reputation: 7927

Use a function to do a JavaScript string replace:

Angular:

$scope.replace = function(string) {
    string = string.replace("/html/profileView.do?", "/photo.do?");
    return string;
}

HTML:

<p>
    {{replace(x.Name)}}
</p>

Fiddle: http://jsfiddle.net/Lvc0u55v/5808/

Edit the object structure to best suit your application, this is only an example.

Upvotes: 1

Related Questions