*LIVE DEMO <http://jsbin.com/guziwamu/1/edit>*

Given the following two directives:

JS:

    angular.module("Directives", []).directive("action", function($compile) 
{
      return {
        restrict: 'A',
        scope: {
          action: '='
        },
        link: function(scope, element) {
          scope.showDialog = false;
          
          var template = "<span dialog='showDialog'>Dialog</span>";
          
          element.append($compile(template)(scope)).on('click', function() {
            console.log("Setting showDialog to true");
            scope.showDialog = true;
          });
        }
      };
    }).directive("dialog", function() {
      return {
        restrict: 'A',
        scope: {
          dialog: '='
        },
        link: function(scope, element) {
          element.hide();
          
          scope.$watch('dialog', function(newValue) {
            console.log("dialog changed to " + newValue); // Not called on 
button click
          });
        }
      };
    });

HTML:

    <button action>Click Here</button>

Could you explain why setting action's showDialog doesn't trigger dialog's 
watcher?

http://stackoverflow.com/q/21810486/247243

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to