AngularJS:如何使用java脚本函数更改跨度的ng-show条件
AngularJS : How to change the ng-show condition of a span using a java script function
我想使用java脚本函数更改ng显示条件。
<span id="error1" ng-show="formerror"><font color="red">{{formerror}}</font></span>
我可以使用获得跨度属性
var scope4 = angular.element($("#error1"))
你可以做到这一点,但我怀疑这是否是一个从Angular应用程序外部操纵其内部的好主意。但这是可能的。
您不需要属性,只需要访问元素的作用域并更改其formerror
属性即可。您可以使用angular.element
的scope
方法来完成此操作。例如:
var $scope = angular.element($("#error1")).scope();
$scope.formerror = 'Fill in required fields.';
$scope.$apply();
演示:http://plnkr.co/edit/cmiQCgnxbvG4hrGY1c18?p=preview
相关文章:
- 使用angularjs ng Show/ng hide显示和隐藏不同的内容
- 我需要NG-IF/NG-SWITCH还是NG-SHOW&NG-HIDE
- 如何在AngularJS视图中使用promise(ng-show)
- AngularJS:如何使用java脚本函数更改跨度的ng-show条件
- ng show和ng hide don'I don’我一秒钟都不工作
- AngularJS:使用ng-show/hide动态维护下拉列表的3种状态(InProgress、Success、Err
- ng-show内容在页面加载过程中闪烁,尽管它不是真实的,并且ng-cloak不适用于FF
- 如何验证使用 ng-repeat、ng-show(角度)动态创建的输入
- 如何使用ng-repeat与清单模型进行ng-show
- AngularJS:ng-show不适用于ng-app
- 为什么我的html节点保持类ng隐藏属性ng show=true
- Angular js ng repeat与条件ng类不应用css类
- AngularJS:为什么ng show没有在IE11上运行
- Angularjs ng-show not working with checkbox with default val
- Angularjs - grouping ng show
- 使用ng-if/ng-show/ng-switch的Angular条件显示会简要地显示这两个元素
- AngularJS ng-show一个条件和多个元素
- Angular ng-show不会连续检查条件
- ng-show在条件为false时隐藏元素的延迟
- 如何使用ng-show和ng-hide在一个简单的条件下管理多个条件