so I did a little experiment based on my project
I create 2 directive, one using isolated scope and the other one is not..
the question are :
is there a way to get scope attribute without using isolated scope ? because in my project I didn't have an isolated scope for the custom directive environment and also I need to access the parent scope
could I manipulate the dom using angular.element('#' + scope.id) ? if not is there a way to do this ?
this is the unisolated custom directive
<test-directive item="item" content="item.context"></test-directive>
this is the js codes
app.directive('testDirective', function() {
return {
restrict: "EA",
scope: false,
template:"<div>test directive</div>",
link: function(scope, elm, attr) {
console.log(attr.item); //I want it like the result gives in line 39
console.log(attr.id); //I want it like the result gives in line 41
console.log(attr.content); //I want it like the result gives in line 43
console.log(scope.name);
}
}
});
this is the isolated one
<isolated-directive id=item.id item="item" content="item.context"></isolated-directive>
this is the js codes
app.directive('isolatedDirective', function() {
return {
restrict: "EA",
scope:{
item:'=item',
id:'=id',
content:'=content',
},
template:"<div>isolated directive</div>",
link:function(scope,elm,attr) {
console.log(scope.item.id);
console.log(scope.id);
console.log(scope.content);
console.log(scope.name); //I want it like the result gives in line 27
}
}
});
and this is the working plunkr
anyone care to help?