我需要从父级获取子元素内的'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>'
};
});