ngChange is called when model changed programmatically

前端 未结 4 1636
旧时难觅i
旧时难觅i 2021-02-08 06:15

I have a problem when angular\'s ng-change is called when model is changed programmatically.

$scope.sendMessage = function() {
    $scope.message = \"Message sen         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 07:00

    You can try with ngModelOptions. See this plunker for reference http://plnkr.co/edit/BdKx62RW5Ls2Iz1H3VR1?p=preview.

    In my example I used ng-model-options="{ updateOn: 'change', debounce: { change: 0 } }" and it seems to work. It only runs function provided in ngChange when I change the selection. On initialize phase message stays empty.

提交回复
热议问题