suppose I do this:
sAngular.app.directive('dostuff', ['$compile', function($compile){
return {
restrict : 'C',
scope: {
someVar : '='
},
link : function(scope, element, attrs){
element.click(function(){
//do stuff
scope.someVar = 'somethingelse';
var dropdownOutput = template();
var compiledOutput = $compile(dropdownOutput)(scope);
scope.$apply();
});
}
}
}]);
how can I make the scope of this directive inherit a variable from the parent scope and yet still have it to be an 'isolate' scope
for instance from angular docs:
= or =attr - set up bi-directional binding between a local scope property and the parent scope property of name defined via the value of the attr attribute. If no attr name is specified then the attribute name is assumed to be the same as the local name. Given and widget definition of scope: { localModel:'=myAttr' }, then widget scope property localModel will reflect the value of parentModel on the parent scope. Any changes to parentModel will be reflected in localModel and any changes in localModel will reflect in parentModel.
however in that case since "any changes in localModel will reflect in parentModel" if I modify a variable in the scope in that directive and then do scope.apply() in that case, it will reflect in the parent scope accordingly and the parent template will be updated with the changes
I also tried doing "scope : true" as a parameter but changes to the scope there followed by the scope.$apply(); will also propagate to the original scope...
Is there a way to make it so that I can copy a scope from the parent scope and still have changes in the variables in that scope not propagate to the parent scope?