1
有人能向我解释,为什么用下面的代码:指令范围和继承
<html ng-app="myApp">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<body>
<div ng-controller="myController">
{{message}}
<div ng-if=true>
{{message}}
<div outer style="background:yellow;padding:20px">
{{message}}
</div>
</div>
</div>
<script>
angular.module('myApp',[])
.controller('myController', function ($scope,$rootScope){
$scope.message="Football game";
})
.directive('outer', function() {
return {
scope: {},
link:{
post:function(scope,element){
scope.message="Basketball.game";
}
}
}
});
</script>
</body>
</html>
我正在为{{消息}} Football Game
所有实例?我期望最后一个是Basketball Game
,因为起初编译器在outer的指令范围内搜索,它可以找到属性message
和Basketball Game
作为值。为什么它不使用它?