Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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 以角度模型为函数参数_Angularjs - Fatal编程技术网

Angularjs 以角度模型为函数参数

Angularjs 以角度模型为函数参数,angularjs,Angularjs,在下面的代码中,我希望能够通过在输入中录制并实时获取角度数据绑定,使菜单的长度动态变化。 字符数: {{x} 角度.module('myApp',[]).controller('namesCtrl',function($scope){ 函数printCharacters(参数){ var结果=[]; 对于(i=1;i这是因为仅在控制器init上调用了printCharacters,此时$scope.nmba=”“ 输入字段中的任何更改都需要调用此func <input typ

在下面的代码中,我希望能够通过在输入中录制并实时获取角度数据绑定,使菜单的长度动态变化。


字符数:

  • {{x}
角度.module('myApp',[]).controller('namesCtrl',function($scope){ 函数printCharacters(参数){ var结果=[];
对于(i=1;i这是因为仅在控制器init上调用了
printCharacters
,此时
$scope.nmba=”“

输入字段中的任何更改都需要调用此func

<input type="number" ng-model="nmba" ng-change="printCharacters(nmba)">

似乎对我有用(我只在输入改变时更新字符)(),但不理解你的逻辑..谢谢@Pankaj,你救了我,我错过了onChange(),谢谢你很高兴知道..谢谢:-)谢谢@Elhay,是的,我错过了变化-正如Pankaj建议的那样。
<input type="number" ng-model="nmba" ng-change="printCharacters(nmba)">
$scope.printCharacters = function(nbma){}