Skip to content Skip to sidebar Skip to footer

Isolated Scope Breaks Attrs.$observe

So I have my nice removeDialog directive as a result of this question: Updating attrs value inside directive - how to do it in AngularJS And now I started playing with isoleted sco

Solution 1:

The content of trigger is not bound to the outer scope anymore. You need to declare it in your isolate scope:

scope: {
    trigger: '='
}

This will bind scope.trigger to the actual expression that you define on the element in which the directive is applied.

This way, attrs.$observe('trigger', function (newValue) {...} should change to

scope.$watch('trigger', function (newValue) {
            if (newValue) {
                angular.element(element).modal('show');
            } else {
                angular.element(element).modal('hide');
            }
        });

Post a Comment for "Isolated Scope Breaks Attrs.$observe"