javascript - Angular directive not getting called when scope is updated -
i have scope modifying variable:
$scope.showcontext = function(context) { $scope.currentcontext = context; .... } i have directive on page:
<div org-chart workflow="currentcontext" /> i have directive:
var orgchartdirective = function($timeout) { return { restrict : 'ae', scope : { workflow : '=', }, link : function(scope, element, attrs) { if (scope.workflow != null) { console.log("**________________________________**"); console.log(scope); } else { alert("workflow null"); } .... when load page, alert workflow null.
when run scope function updates $scope.currentcontext, nothing else happens. should called again, right?
edited say: have on page , show variable getting set after call scope method:
workflow----> {{currentcontext.workflow}}
you have watch/observe property change in link function this:
attrs.$watch('workflow', function() { //do whatever logic want }); read more observers , watchers , how can use them here: ben naddal tutorial on observers , watchers
try gist: gist observers , watchers
Comments
Post a Comment