如果找不到图像-angularjs,则替换为默认图像

for*_*fly 4 javascript image angularjs

如果在AngularJS中未定义图像路径,那么检查和显示的最佳条件可能是什么.我试过这样的:

HTML:
<div ng-src="{{imageUrl}}" == "null" || src="img/avatar.png" >

CONTROLLER:
$scope.imageUrl="125.178.1.127/uploads/image" +$scope.imageName;
Run Code Online (Sandbox Code Playgroud)

如果$ scope.imageName未定义,我必须加载/显示默认图像 img/avatar.png

Baz*_*nga 7

这应该工作:

<div ng-src="{{imageName ? imageUrl : 'img/avatar.png'}}">
Run Code Online (Sandbox Code Playgroud)