Angularjs Img src不';更新源代码时不会更改
我有一个ionic 1应用程序,我正在尝试动态更改img源。我以为我所要做的就是更新链接到这个源的范围,但它不起作用。你知道哪里有问题吗Angularjs Img src不';更新源代码时不会更改,angularjs,ionic-framework,Angularjs,Ionic Framework,我有一个ionic 1应用程序,我正在尝试动态更改img源。我以为我所要做的就是更新链接到这个源的范围,但它不起作用。你知道哪里有问题吗 my View <div ng-if="isList" class="item style-list" ng-repeat="(key, item) in items" ng-click="goTo(item)"> <div class="img-container" ng-if="isList">
my View
<div ng-if="isList" class="item style-list" ng-repeat="(key, item) in items"
ng-click="goTo(item)">
<div class="img-container" ng-if="isList">
<m-img encode="true" src="item.image"></m-img>
</div>
<h1 ng-bind="item.title"></h1>
<p ng-bind="item.resume" ng-if="item.resume"></p>
<p ng-bind-html="stripHtml(item.description) | mCut:100" ng-if="!item.resume"></p>
</div>
my Controller
$scope.$on("update-data", function(event, args) {
$scope.items[1].description =
args.response.results[0].item.description;
$scope.items[1].id = args.response.results[0].item.id;
$scope.items[1].image = args.response.results[0].item.image;
$scope.items[1].resume = args.response.results[0].item.resume;
$scope.items[1].title = args.response.results[0].item.title;
});
我的观点
我的控制器
$scope.$on(“更新数据”,函数(事件,参数){
$scope.items[1]。说明=
args.response.results[0]。item.description;
$scope.items[1]。id=args.response.results[0]。item.id;
$scope.items[1]。image=args.response.results[0]。item.image;
$scope.items[1]。resume=args.response.results[0]。item.resume;
$scope.items[1]。title=args.response.results[0]。item.title;
});
我的m-img组件
html
<div class="thumb-size notloaded">
<div class="thumb" ng-if="imgStyle" ion-img-cache-bg ng-
style="imgStyle">
</div>
</div>
html
我的m-img JS有点广泛,这里的错误似乎在mImg组件中,因为代码没有在
src
属性上查看更改(但您只在url
属性上执行此操作,此处未使用该属性),并且触发了一些逻辑(在$scope.load
中定义)来更新视图
即使在src
上,您也应该添加一个观察程序,并触发加载方法更新$scope.imgSrc
变量,这将更新您的视图
controller: function($scope, $timeout, $mAppDef) {
$scope.$watch('src', function() {
$scope.load()
});
}
发布m-img组件的代码刚刚发布!我以前没有使用过爱奥尼亚,但你试过吗?我试过了,结果相同:/,正如卡里姆指出的,它可能与我的m-img组件有关。