[英]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 它给我“ url”作为路径中的字符串
It gives me the image source url as url://my/image/path
due to "url" in the image path my image cannot be loaded. 由于无法加载我的图像的图像路径中的“ url”,它为我提供了图像源URL为
url://my/image/path
。
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像这样:
ng-src="{{removeUrl(row.avatar)}}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.