我需要在父元素的子元素中获取“c”属性(请参阅jsfiddle) 是否有可能?如何绑定父级范围属性?
<div ng-app="myApp">
<box c="yellow">
<item>item</item>
</box>
</div>
angular.module('myApp', [])
.directive('box', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
template: '<div ng-transclude></div>'
};
})
.directive('item', function() {
return {
restrict: 'E',
replace: true,
scope: {c:'='},
template: '<div>c:{{c}}</div>'
};
});
尝试覆盖链接函数和访问范围$ parent – 2013-02-11 12:23:58