Cannot find controller with name MyController
If you have just created new page using AngularJS and getting error Cannot find controller with name MyController means you have not initialize your new controller yet as shown below:
- To fix this issue please initialize controller as below:
<!DOCTYPE html> <html ng-app="myapp3"> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> <script type="text/javascript"> var app = angular.module('myapp3', []); app.controller('MyController', function($scope){ $scope.variable = "AngularJS Hello World!!!"; }); </script> </head> <body ng-controller="MyController"> <div> <p>{{variable}}</p> </div> </body> </html>
- Run this code in Plunker here
Hi,
I am getting cannot find module and also cannot find controller error and also multiple file annotations error.Please help .
My file:
var validation = angular.module(‘my’, []);
validation.controller(‘mycontroller’ , function($scope) {
$scope.firstName = “madhuri”;
$scope.email = “madhuri@gmail.com”;
$scope.age = “24”;
$scope.pattern = /^\d*$/;
});
Name :
please provide the name
Email:
please provide the valid email address
<!– please provide the valid email address –>
age :
please provide the correct age
Thanks,
Hi,
I am getting cannot find controller with name and also cannot find module as well as multiple annotions found at this line.
Please help
My code :
var validation = angular.module(‘my’, []);
validation.controller(‘mycontroller’ , function($scope) {
$scope.firstName = “madhuri”;
$scope.email = “madhuri@gmail.com”;
$scope.age = “24”;
$scope.pattern = /^\d*$/;
});
Name :
please provide the name
Email:
please provide the valid email address
<!– please provide the valid email address –>
age :
please provide the correct age