How to add a <a> link to content inside $ scope.var of AngularJS

I have my data from my controller as shown below.

controller:

$http.get('json/projects.json').success(function(data) { $scope.projects = data; }); 

my data in the json file looks something like this:

JSON:

 { ... projects = ['hello world', 'www.google.com', 'hello world.'] } 

HTML:

 <div ng-repeat='p in projects'> {{p}} </div> 

My question is how to display "www.google.com" as a link, not plain text?

+6
source share
1 answer

You can use the liky filter from ngSanitize module: https://docs.angularjs.org/api/ngSanitize/filter/linky

I'm afraid you will have to change 'www.google.com' to 'http://www.google.com'

+2
source

Source: https://habr.com/ru/post/985674/


All Articles