在angularjs手动射击$手表事件 [英] Firing $watch event manually in angularjs
本文介绍了在angularjs手动射击$手表事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用这个code:
$scope.$watch('message', function()
{
// the code
});
有什么办法来手动火灾的消息改变事件,因此code将被执行?
Is there any way to fire change event of message manually, so the code will be executed?
推荐答案
几个选项:
-
使用$范围。$适用()来运行消化环路呼叫所有手表前pressions的
Use $scope.$apply() to run the digest loop which call all of the watch expressions
把你内心的手表code函数里面手动调用它
Put you inner watch code inside a function and call it manually
修改消息:)
Change messages
:)
这篇关于在angularjs手动射击$手表事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文