我正在尝试将从函数传递的参数值分配给ng-show,但毫无用处...我想做的是在文本框中单击click并为ng-show分配值。函数被调用,但未分配值...
<span ng-show="show.error"> <font color="red">Error</font> </span>
<input type="text" ng-model="template.name" ng-click="checkerrorexist(this)"></td>
$scope.checkerrorexist = function(scope){
$scope.apply(function() {
$scope.show.error=true;
})
};
我不知道我要去哪里错了...有人可以帮忙...
该代码或多或少是正确的,但是在看不到您的应用程序更大范围的情况下,我无法分辨出最大的潜在问题是什么。无论如何调试这段代码。
HTML:
<span ng-show="show.error"> <font color="red">Error</font> </span>
<input type="text" ng-model="template.name" ng-click="checkerrorexist()"></td>
控制器代码:
$scope.show = { error: false };
$scope.checkerrorexist = function(){
$scope.show.error = true;
};
$ scope。$ apply()是不需要的,因为当角度更新/更改范围的一部分自动触发摘要循环时,这就是$ apply为我们所做的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句