執行程式碼的時候,google developer tool封包The controller with the name 'my-injectorCtrl' is not registered的錯誤,如果我想使用推斷式註入,這樣寫哪裡錯了。本人菜鳥,實在想不出哪裡錯了,望各位大神指點,感激不盡!
<p ng-app>
<p ng-controller="my-injectorCtrl">
<span>{{TestInjector1}}</span>
</p>
</p>
var myInjectorModule = angular.module("MyInjectorModule",[]);
var myInjectorCtrl = function($scope){
$scope.TestInjector1 = "Hello Injector";
}
myInjectorModule.controller("myInjectorCtrl",myInjectorCtrl);
曾经蜡笔没有小新2017-05-15 17:15:07
改成下面這樣就可以了
<p ng-app="MyInjectorModule">
<p ng-controller="MyInjectorCtrl">
<span>{{TestInjector1}}</span>
</p>
</p>
var myInjectorModule = angular.module("MyInjectorModule",[]);
var myInjectorCtrl = function($scope){
$scope.TestInjector1 = "Hello Injector";
}
myInjectorModule.controller("MyInjectorCtrl",myInjectorCtrl);