scope.$watch in a directive isn't being called after AJAX request

前端 未结 1 2005
眼角桃花
眼角桃花 2020-12-13 09:48

I have the following directive:

MyApp.directive(\'myFilter\', [\'$filter\',\'$rootScope\',
function($filter, $rootScope)
{
    var dir = {};
    dir.restrict         


        
相关标签:
1条回答
  • 2020-12-13 10:15

    $watch expects an expression that can be either a function or a string. So, it'll work if you change it to

    scope.$watch('model', function() { ... });
    

    or

    scope.$watch(function() { return scope.model; }, function() { ... });
    

    Check out this jsFiddle.

    0 讨论(0)
提交回复
热议问题