首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在AngularJS中如何触发指令测试中的ng更改?

在AngularJS中如何触发指令测试中的ng更改?

提问于 2018-02-07 04:59:44
回答 2关注 0查看 176

有以下AngularJS指令,该指令创建一个input元素。输入ng-change属性运行doIt()功能。

指令:

...
template: "<input ng-model='myModel' ng-change='doIt()' type='text'>" 

测试:

el.find('input').trigger('change') // Dos not trigger ng-change

现场演示(ng-Change):...

change事件,而不是使用ng-change属性。
template: "<input ng-model='myModel' type='text'>",
link: function(scope, element, attrs) {
  element.bind('change', function(event) {
    scope.doIt();
  });
}
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档