Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

关于报The controller with the name '' is not registered的问题

????执行代码的时候,google developer tool报The controller with the name 'my-injectorCtrl' is not registered的错误,如果我想使用推断式注入,这样写哪里错了。本人菜鸟,实在想不出哪里错了,望各位大神指点,感激不尽!

HTML文件的内容:

<div ng-app>
    <div ng-controller="my-injectorCtrl">
        <span>{{TestInjector1}}</span>
    </div>
</div>

JS文件的内容:

var myInjectorModule = angular.module("MyInjectorModule",[]);

var myInjectorCtrl = function($scope){
    $scope.TestInjector1 = "Hello  Injector";
}

myInjectorModule.controller("myInjectorCtrl",myInjectorCtrl);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<div ng-app="myInject">
    <div ng-controller="myController">
        <span>{{TestInjector1}}</span>
    </div>
</div>
var myInject = angular.module("myInject",[]);
myInject.controller("myController", ["$scope", function($scope) {
    $scope.TestInjector1= "Hello  Injector";
}])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...