Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

json

angularjs

I have got my data from my controller like below.

controller:

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

my data in json file is 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 rather than a simple text?

like image 716
wildcolor Avatar asked Apr 22 '15 11:04

wildcolor


1 Answers

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

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

like image 164
syymza Avatar answered Oct 30 '22 04:10

syymza