我一直在这个特定的测试我的头几个小时。我相信所展示的指令应该可以工作,但我正在传递给隔离范围的值未定义。AngularJS隔离范围没有被传递到指令
代码:
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/
任何帮助将是AP preciated,我一定在做错事。
改变你的小提琴,看 –