Javascript angularJS中的控制器链接
1:加载资源失败file:///C:/Users/Faizan/WebstormProjects/AngularJS%20emit%20broadcase%20controller/js/controller.js.jsJavascript angularJS中的控制器链接,javascript,angularjs,controller,Javascript,Angularjs,Controller,1:加载资源失败file:///C:/Users/Faizan/WebstormProjects/AngularJS%20emit%20broadcase%20controller/js/controller.js.js 2:未捕获错误:[$injector:modulerr]$injector/modulerr?p0=myApp&p1=Error%3A%…rJS%2520emit%2520broadcase%2520controller%2Fjs%2FANGRAL.min.js%3A17%3A
2:未捕获错误:[$injector:modulerr]$injector/modulerr?p0=myApp&p1=Error%3A%…rJS%2520emit%2520broadcase%2520controller%2Fjs%2FANGRAL.min.js%3A17%3A431)确保在ng应用程序中引用了正确的模块。
包含您的代码,并且不会产生错误
您可以通过将ng应用程序(在“小提琴选项”下)更改为类似以下内容来重现错误2:
另外,请确保在javascript文件之前引用angular,例如controller.js。使用服务器,
http://
。我已选中仍然面临未捕获引用错误:angular未定义控制器。js:9未捕获错误:[$injector:modulerr]…rJS%2520emit%2520broadcase%2520controller%2Fjs%2Fangular.min.js%3A17%3A431)对angular的引用必须在controller.js文件之前。太好了,我在答案中添加了这个建议。
/**
* Created with JetBrains WebStorm.
* User: Faizan
* Date: 3/7/14
* Time: 6:09 PM
* To change this template use File | Settings | File Templates.
*/
angular.module("myApp",[])
.controller("CtrlParent",function($scope){
$scope.ParentFunc= function(){
alert("This is Parent");
// $scope.$on("hello");
}
})
.controller('CtrlBigChild',function($scope){
$scope.BigChildFunc= function(){
alert("This is Big Child");
// $scope.$on("hello");
}
})
.controller('CtrlChildOne',function($scope){
$scope.ChildOneFunc= function(){
alert("This is Child One");
// $scope.$on("hello");
}
})
.controller('CtrlChildTwo',function($scope){
$scope.CtrlChildTwoFunc= function(){
alert("This is Child Two");
// $scope.$on("hello");
}
})
.controller('CtrlChildOneChild',function ($scope){
$scope.ChildOneChildFunc= function(){
alert("This is Child one's Child");
// $scope.$on("hello");
}
})
.controller('CtrlChildTwoChild',function($scope){
$scope.ChildTwoChildFunc= function(){
alert("This is Child Two's Child");
// $scope.$on("hello");
}
})