简体   繁体   中英

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 ?

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)}}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM