几个小时以来,我一直在为这个特殊的测试挠头。我相信演示的指令应该可以工作,但是对于传递给隔离范围的值,我没有定义。
代码:
html
<!doctype html>
<html ng-app="myApp">
<body>
<a ng-href="#" class="test-scope" name="test">Console should say 'test' but gives undefined</a>
</body>
</html>
javascript
angular.module('myApp', [])
.directive('testScope', function() {
return {
restrict: 'C',
scope: {
name: "="
},
link: function(scope, element, attrs) {
console.log(scope.name);
}
};
});
这是小提琴:http: //jsfiddle.net/jPtb3/8/
任何帮助将不胜感激,我一定做错了什么。