Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 在angular js中,如果ng if为true,如何调用函数?_Angularjs - Fatal编程技术网

Angularjs 在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

我是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-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();">