angularjs - Angular gives same generic error -
when try run angular code , gives generic error message though nor problem module api or name. example, in case, put name value pairs separated in object semi colon in config method. after changing comma, fine now. not tell exact cause in config not in module name. how find exact cause?
uncaught error: [$injector:modulerr] failed instantiate module myapp due to: error: [$injector:nomod] module 'myapp' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument.
it's common error. occurs when ng-app name declared in template differs 1 used in script, example :
index.html
<html lang="en" ng-app="app"> <head> <meta charset="utf-8"> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script> <script src="script.js"></script> </head> <body> </body> </html> script.js
angular.module('app', []); angular.module('myapp') // <-- error occurs here, should 'app' .controller('examplecontroller', ['$scope', '$http', function($scope, $http) { // controller code here }]);
Comments
Post a Comment