我有这个 jsFiddle:http: //jsfiddle.net/HMZuh/1/
其中包含此 html
<div ng-app ng:controller="ShowHideController">
<div ng-show='showMe'>
<img ng-src="{{imageSource}}"/>
</div>
<button ng-click='showImage()'> show image </button>
<div>
这个脚本:
function ShowHideController($scope) {
$scope.showMe = false;
$scope.imageSource = '';
$scope.showImage = function(){
$scope.showMe = true;
$scope.imageSource = 'https://www.google.com/images/srpr/logo3w.png';
}
}
我得到一个 404,在尚未设置源时找不到图像,当 showMe 为假时,有什么方法可以防止这种情况发生吗?
</p>