简体   繁体   English

当 JQuery 修改值时,angularjs 检测输入的变化

[英]angularjs detect changes in input when value is modified by JQuery

I have a input (text + button).我有一个输入(文本+按钮)。 When I press the button (select date and time) and the library set value in input text.当我按下按钮(选择日期和时间)和输入文本中的库设置值时。 I like to detect changes with angularJs or JQuery for this field but it does not work.我喜欢使用 angularJs 或 JQuery 检测此字段的更改,但它不起作用。

I tried with (in directive):我试过(在指令中):

$scope.$watch('namevarmodel', function() {
    alert('test');
},true);

And JQuery:和 JQuery:

<script>
    $('#nameinput').change(function() {
        alert( "test." );
    });
</script>

Any suggestions?有什么建议?

Angular provides directives that automagically keeps watching your inputs. Angular 提供了自动持续观察你输入的指令。 You could check the angular documentation for ng-change and you could do something like this:您可以检查 ng-change 的角度文档,您可以执行以下操作:

<input ng-change="action()">...</input>

I hope this helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM