0
/**
 * 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");
 }
 })

1: Failed to load resource file:///C:/Users/Faizan/WebstormProjects/AngularJS%20emit%20broadcase%20controller/js/controller.js.js

2 :Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.10/$injector/modulerr?p0=myApp&p1=Error%3A%...rJS%2520emit%2520broadcase%2520controller%2Fjs%2Fangular.min.js%3A17%3A431)

asked Mar 10, 2014 at 6:25
1
  • Use server, http://. Commented Mar 10, 2014 at 6:33

1 Answer 1

1

Make sure you are referencing the correct module in ng-app.
<body ng-app="myApp">

This demo contains your code, and produces no errors.

You can reproduce error 2 by changing ng-app (under fiddle options) to something else like:
<body ng-app="banana">


And, make sure that you reference angular before your javascript filess, such as controller.js.

answered Mar 10, 2014 at 6:46

3 Comments

i have chekcked still facing Uncaught ReferenceError: angular is not defined controller.js:9 Uncaught Error: [$injector:modulerr] errors.angularjs.org/1.2.10/$injector/…...rJS%2520emit%2520broadcase%2520controller%2Fjs%2Fangular.min.js%3A17%3A431)
reference to angular must be before your controller.js file.
great, i added that suggestion to the answer.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.