本质上,我希望能够访问我创建的指令的父范围,但我也希望能够访问我放置在元素上的属性。
例如相关的js
app.directive('testDirective', function(){
return {
restrict:"E",
templateUrl:"directive.html",
scope:{
testAttribute: '='
}
};
});
app.controller('mainCtrl', function($scope){
$scope.name = 'henry'
}
索引.html
<div ng-controller="mainCtrl">
<test-directive test-attribute="Hello"></test-directive>
</div>
指令.html
{{testAttribute}}
{{name}}
输出是“Hello”而不是“Hello Henry”
所以只是为了澄清,我想做的就是访问属性和父范围。