Angular的ng-src和data-src一起不能工作



当ng-src和data-src一起使用时,它不起作用,像这样:

HTML:

<div ng-app="app" ng-controller="MainController">
    <img ng-src="{{userpic}}" data-src="{{userpic}}" />
</div>

JS:

angular.module('app', [])
    .controller('MainController', ['$scope',
function ($scope) {
    $scope.userpic = 'http://placehold.it/350x150';
}]);

如果你跳过data-src="{{userpic}}",它又工作了,我不知道为什么。

jsfiddle: http://jsfiddle.net/mKWVh/

你实际上不需要添加data-src属性,如果你想要指令符合某些IE版本,那么你可以简单地使用data-ng-src="{{userpic}}

<div ng-app="suncake" ng-controller="MainController">
    <img data-ng-src="{{userpic}}" width="69" height="69" />
</div>

最新更新