2014-11-16 48 views
-1

我按照教程阅读文档,但不明白我在做什么错误。我总是得到。这里就是我有

<!DOCTYPE html> 
<html ng-app="myApp"> 
<head> 
    <title></title> 
    <script type="text/javascript" src="bower_components/angular/angular.js"></script> 
    <script type="text/javascript" src="directives/communicate.js"></script> 

    <script type="text/javascript"> 
     var app = angular.module('myApp', []); 

     app.controller('abc', function($scope) { 

     }); 

     app.directive('abd', function() { 
      return { 
       restrict: 'AE', 
       controller: function($scope) { 
        $scope.tab = []; 
        console.log('hello') 

        this.tab = function() { 
         $scope.tab.push('test'); 
        } 
       } 
      } 
     }); 

     app.directive('def', function() { 
      return { 
       require: 'abc', 
       link: function(scope, element, attrs, abcCtrl) { 
        console.log(abcCtrl.tab); 
       } 
      } 
     }); 
    </script> 
</head> 
<body> 
    {{ 1 + 1 }} 
    <div def abc></div> 
</body> 
</html> 

在最后,我总是得到错误:[$编译:ctreq]控制器“ABC”,由指令所要求的“高清”,不能被发现。怎么来的 ?

回答

-2

Got it!这是一个错字:(

app.directive('abd', function() { 
... 

应该

app.directive('abc', function() { 
... 
相关问题