Bhavya Patel
Bhavya Patel

Reputation: 1

How to use img tag in Angular JS?

When I write :

<img ng-src={{row.avatar}}> 

It gives me the "url "as string in the path

It gives me the image source url as url://my/image/path due to "url" in the image path my image cannot be loaded.

How should I do this ?

Upvotes: 0

Views: 67

Answers (1)

illeb
illeb

Reputation: 2947

So try to get rid of it.

In your controller, create a function like:

$scope.removeUrl = function(url){
   return url.replace('url://', '');
}

and your ng-src like so:

ng-src="{{removeUrl(row.avatar)}}"

Upvotes: 2

Related Questions