javascript - AngularJS: Failed to instantiate module error -


i know question has been asked, not find answer personal case. i'm sure it's stupid thing didn't notice i'm not getting out of it.

i'll post code have (it's not much) because can not find real origin of error.

this app.js file:

'use strict';   var myapp = angular.module('myapp', [   'ngroute',   'appcontrollers' ]);  myapp.config(['$routeprovider', function($routeprovider) {   $routeprovider.when('/faq', {     templateurl: 'faq/faq.html',     controller: 'faqctrl'   }).   when('/log', {     templateurl: 'log/log.html',     controller: 'logctrl'   }).   [...]   when('/settings', {     templateurl: 'settings/settings.html',     controller: 'settingsctrl'   }).   otherwise({redirectto: '/homepage'}); }]); 

while here hold controllers, controllers.js:

'use strict';  /* controllers */  var appcontrollers = angular.module('appcontrollers', []);  appcontrollers.controller('faqctrl', [function() {  }]);  appcontrollers.controller('homepagectrl', [function() {  }]);  [...]  appcontrollers.controller('settingsctrl', function($scope, $http) { /*   $scope.mydata = {};   $scope.mydata = function(item, event) {      var response = $http.get("myurl");      response.success(function() {        alert("ok");     });      response.error(function() {        alert("error");     });  */ }); 

and here settings.html:

<div ng-controller="settingscontroller" >     <button ng-click="mydata.doclick(item, $event)">send ajax request</button>     <br/>     data server: {{mydata.fromserver}}   </div> 

now, if run code inside settingsctrl commented works fine, if decomment it, page not end loading (even if don't go settings section) , error this:

error: [$injector:modulerr] failed instantiate module myapp due to: [$injector:modulerr] failed instantiate module appcontrollers due to: [$injector:nomod] module 'appcontrollers' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument. 

what did miss?

i'm sure stupid thing, i'm newbie angularjs.

thanks in advance.

when uncomment curly braces not closed properly.

appcontrollers.controller('settingscontroller', function($scope, $http) {    $scope.mydata = {};   $scope.mydata = function(item, event) {      var response = $http.get("myurl");      response.success(function() {        alert("ok");     });      response.error(function() {        alert("error");     });    } }); 

http://plnkr.co/edit/4sltz2bwai9zm9flkyc7?p=preview

one more issue, controller name not matching have figured out already.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -