When one directive (call it el2) is nested within another (call it el1), I cannot access variables "locally declared" in el1 (e.g. variables produced by ng-repeat, ng-init etc) from el2.
This fiddle demonstrates the issue. Code follows:
var myApp = angular.module('myApp',[]);
// define blue `el1` element which contains an `el2` child:
myApp.directive('el1', function() {
return {
restrict: 'E',
link: function($scope) {
},
replace: true,
template: '<div ng-init="value1 = 1;">' +
'value1: {{ value1 }}' +
' <el2></el2>' +
'</div>',
scope: {
}
};
});
// define green `el2` element:
myApp.directive('el2', function() {
return {
restrict: 'E',
link: function($scope) {
},
replace: true,
template: '<span ng-init="value2 = 2;">' +
'value1: {{ value1 || "UNDEFINED" }} value2: {{ value2 }}</span>',
scope: {
value1: '='
}
};
});
How can I access value1 in the el2 directive? Is there any way that does not involve modifying the scope explicitly through the link function or controller?
typeIdandactionType) from camelCase to dash-delimiting! Stupid me! Do you want to post the solution?