angular.js - Regarding the problem of reporting The controller with the name '' is not registered
巴扎黑
巴扎黑 2017-05-15 17:13:07
0
2
2110

When executing the code, the google developer tool reported the error The controller with the name 'my-injectorCtrl' is not registered. If I want to use inferential injection, what is wrong with this writing. I'm a newbie and I really can't figure out what I'm doing wrong. I hope you can give me some advice. I'd be very grateful!

Content of HTML file:

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

Contents of JS file:

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

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

myInjectorModule.controller("myInjectorCtrl",myInjectorCtrl);
巴扎黑
巴扎黑

reply all(2)
阿神
<p ng-app="myInject">
    <p ng-controller="myController">
        <span>{{TestInjector1}}</span>
    </p>
</p>
var myInject = angular.module("myInject",[]);
myInject.controller("myController", ["$scope", function($scope) {
    $scope.TestInjector1= "Hello  Injector";
}])
曾经蜡笔没有小新

Just change it to the following

HTML file content:

<p ng-app="MyInjectorModule">
    <p ng-controller="MyInjectorCtrl">
        <span>{{TestInjector1}}</span>
    </p>
</p>

JS file content:

var myInjectorModule = angular.module("MyInjectorModule",[]);
var myInjectorCtrl = function($scope){
    $scope.TestInjector1 = "Hello  Injector";
}
myInjectorModule.controller("MyInjectorCtrl",myInjectorCtrl);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template