Angularjs 在angular js中,如果ng if为true,如何调用函数?
我是angular js的新手,尝试在ng if为true时调用函数 我的代码=>Angularjs 在angular js中,如果ng if为true,如何调用函数?,angularjs,Angularjs,我是angular js的新手,尝试在ng if为true时调用函数 我的代码=> ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon= false && hellow()" ng repeat=“post.postmages中的图像”ng if=“$index应该是这样的 ng-repeat="image in post.postImages" ng
ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon= false && hellow()"
ng repeat=“post.postmages中的图像”ng if=“$index应该是这样的
ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon= false; hellow()";
ng repeat=“post.postmages中的图像”ng if=“$index定义角度
(模块和ng应用程序
),然后控制器
绑定函数hellow
,然后更改如下:
<div ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon=false; hellow();">
工作
使用脚本标记更新。一旦分配了ng init值,它的调用方法当ng if为非真时,post.postImages的大小请为?8………您必须定义角度控制器来处理$scope.hellow
函数。如果我只写$scope.hellow=function(){alert('hi');},是否与上面的post不同; 在脚本标记中。它不会起作用吗???@Sajeetharan:在Qstn中。它被写入image.showdeletecon=false&&hellow()
,并且在您的回答中(编辑之前)hellow()
超出了ng init
@nayanchowdhury:是的,它会工作,但需要定义和引导,请参阅
ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon= false; hellow()";
<div ng-repeat="image in post.postImages" ng-if="$index <= 3" ng-init="image.showDeleteIcon=false; hellow();">