Error: [ng:areq] Argument 'LoginCtrl' is not a function, got undefined

Hi,

Its really been so frustrated, i have been stuck with this issue and gone through forum with same topics but don’t see any solution. hope someone there to help me out from this issue.

App Controller files code:

// Ionic Starter App
’use strict’;
// angular.module is a global place for creating, registering and retrieving Angular modules
// ‘starter’ is the name of this angular module example (also set in a attribute in index.html)
// the 2nd parameter is an array of 'requires’
angular.module(‘starter’, [‘ionic’])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

  // Don't remove this line unless you know what you are doing. It stops the viewport
  // from snapping when text inputs are focused. Ionic handles this internally for
  // a much nicer keyboard experience.
  cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}

});
})

.config(function($stateProvider, $urlRouterProvider) {

// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state’s controller can be found in controllers.js
$stateProvider

.state('login', {
  cache:false,
  url: '/login',
  templateUrl: 'templates/login.html',
  controller: 'LoginCtrl'
})

;

// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise(’/login’);

});

Controllers.js file code

‘use strict’;
angular.module(‘starter.controllers’, [])

.controller(‘LoginCtrl’, function($scope) {
console.log(‘login controller loaded’);
//$scope.data = {};

/*$scope.login = function() {
  console.log("LOGIN user: " + $scope.data.username + " - PW: " + $scope.data.password);
}*/

})

Now Index.html code is here

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>

and Login.html templates is here

Username Password Keep me Signed In Sign In No Registered yet? Sign Up

i have tried everything and stuck here and getting error is below:

Error: [ng:areq] Argument ‘LoginCtrl’ is not a function, got undefined
http://errors.angularjs.org/1.5.3/ng/areq?p0=LoginCtrl&p1=not%20a%20function%2C%20got%20undefined
minErr/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13438:12
assertArg@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15214:11
assertArgFn@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15224:3
$controller@http://localhost:8100/lib/ionic/js/ionic.bundle.js:23373:9
self.appendViewElement@http://localhost:8100/lib/ionic/js/ionic.bundle.js:59900:24
ionicViewSwitcher.create/switcher.render@http://localhost:8100/lib/ionic/js/ionic.bundle.js:57893:29
ionicViewSwitcher.create/switcher.init@http://localhost:8100/lib/ionic/js/ionic.bundle.js:57813:11
self.render@http://localhost:8100/lib/ionic/js/ionic.bundle.js:59759:5
self.register@http://localhost:8100/lib/ionic/js/ionic.bundle.js:59717:5
updateView@http://localhost:8100/lib/ionic/js/ionic.bundle.js:65398:11
.compile/</<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:65375:11
$RootScopeProvider/this.$get</Scope.prototype.$broadcast@http://localhost:8100/lib/ionic/js/ionic.bundle.js:30718:15
transitionTo/$state.transition<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:52157:11
processQueue@http://localhost:8100/lib/ionic/js/ionic.bundle.js:29127:28
scheduleProcessQueue/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:29143:27
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost:8100/lib/ionic/js/ionic.bundle.js:30395:16
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:8100/lib/ionic/js/ionic.bundle.js:30211:15
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:8100/lib/ionic/js/ionic.bundle.js:30503:13
done@http://localhost:8100/lib/ionic/js/ionic.bundle.js:24824:36
completeRequest@http://localhost:8100/lib/ionic/js/ionic.bundle.js:25022:7
requestLoaded@http://localhost:8100/lib/ionic/js/ionic.bundle.js:24963:9

return logFn.apply(console, args);

ionic.bundle.js (line 26794)

IS THERE ANYONE WHO CAN HELP ME OUT REALLY, THANKS IN ADVANCE

Heey, i think your issue is that you don’t add the starter.controllers as a dependecy too the angular module.starter, you should put it like this :
angular.module('starter', ['ionic', 'starter.controllers'])

hope it helps

thanks for your reply really i appreciate, i just replaced the code you suggested and getting this issue

Error: [$injector:modulerr] Failed to instantiate module starter due to:
[$injector:modulerr] Failed to instantiate module starter.controllers due to:
[$injector:nomod] Module ‘starter.controllers’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

minErr/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13438:12
module/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15404:17
ensure@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15328:38
module@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15402:14
loadModules/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17894:22
forEach@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13691:11
loadModules@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17878:5
loadModules/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17895:40
forEach@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13691:11
loadModules@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17878:5
createInjector@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17800:19
bootstrap/doBootstrap@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15080:20
bootstrap@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15101:12
angularInit@http://localhost:8100/lib/ionic/js/ionic.bundle.js:14986:5
@http://localhost:8100/lib/ionic/js/ionic.bundle.js:44079:5
trigger@http://localhost:8100/lib/ionic/js/ionic.bundle.js:16497:7
defaultHandlerWrapper@http://localhost:8100/lib/ionic/js/ionic.bundle.js:16787:3
createEventHandler/eventHandler@http://localhost:8100/lib/ionic/js/ionic.bundle.js:16775:9

http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=starter.controllers&p1=[%24injector%3Anomod]%20Module%20’starter.controllers’%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument. http%3A%2F%2Ferrors.angularjs.org%2F1.5.3%2F%24injector%2Fnomod%3Fp0%3Dstarter.controllers minErr%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13438%3A12 module%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15404%3A17 ensure%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15328%3A38 module%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15402%3A14 loadModules%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17894%3A22 forEach%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13691%3A11 loadModules%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17878%3A5 loadModules%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17895%3A40 forEach%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13691%3A11 loadModules%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17878%3A5 createInjector%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17800%3A19 bootstrap%2FdoBootstrap%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15080%3A20 bootstrap%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15101%3A12 angularInit%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A14986%3A5 %40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A44079%3A5 trigger%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16497%3A7 defaultHandlerWrapper%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16787%3A3 createEventHandler%2FeventHandler%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16775%3A9
minErr/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13438:12
loadModules/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17917:15
forEach@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13691:11
loadModules@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17878:5
loadModules/<@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17895:40
forEach@http://localhost:8100/lib/ionic/js/ionic.bundle.js:13691:11
loadModules@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17878:5
createInjector@http://localhost:8100/lib/ionic/js/ionic.bundle.js:17800:19
bootstrap/doBootstrap@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15080:20
bootstrap@http://localhost:8100/lib/ionic/js/ionic.bundle.js:15101:12
angularInit@http://localhost:8100/lib/ionic/js/ionic.bundle.js:14986:5
@http://localhost:8100/lib/ionic/js/ionic.bundle.js:44079:5
trigger@http://localhost:8100/lib/ionic/js/ionic.bundle.js:16497:7
defaultHandlerWrapper@http://localhost:8100/lib/ionic/js/ionic.bundle.js:16787:3
createEventHandler/eventHandler@http://localhost:8100/lib/ionic/js/ionic.bundle.js:16775:9

http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=starter&p1=[%24injector%3Amodulerr]%20Failed%20to%20instantiate%20module%20starter.controllers%20due%20to%3A [%24injector%3Anomod]%20Module%20’starter.controllers’%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument. http%3A%2F%2Ferrors.angularjs.org%2F1.5.3%2F%24injector%2Fnomod%3Fp0%3Dstarter.controllers minErr%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13438%3A12 module%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15404%3A17 ensure%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15328%3A38 module%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15402%3A14 loadModules%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17894%3A22 forEach%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13691%3A11 loadModules%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17878%3A5 loadModules%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17895%3A40 forEach%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13691%3A11 loadModules%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17878%3A5 createInjector%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17800%3A19 bootstrap%2FdoBootstrap%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15080%3A20 bootstrap%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15101%3A12 angularInit%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A14986%3A5 %40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A44079%3A5 trigger%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16497%3A7 defaultHandlerWrapper%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16787%3A3 createEventHandler%2FeventHandler%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16775%3A9 http%3A%2F%2Ferrors.angularjs.org%2F1.5.3%2F%24injector%2Fmodulerr%3Fp0%3Dstarter.controllers%26p1%3D%255B%2524injector%253Anomod%255D%2520Module%2520’starter.controllers’%2520is%2520not%2520available!%2520You%2520either%2520misspelled%2520the%2520module%2520name%2520or%2520forgot%2520to%2520load%2520it.%2520If%2520registering%2520a%2520module%2520ensure%2520that%2520you%2520specify%2520the%2520dependencies%2520as%2520the%2520second%2520argument.%250Ahttp%253A%252F%252Ferrors.angularjs.org%252F1.5.3%252F%2524injector%252Fnomod%253Fp0%253Dstarter.controllers%250AminErr%252F%253C%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A13438%253A12%250Amodule%252F%253C%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A15404%253A17%250Aensure%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A15328%253A38%250Amodule%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A15402%253A14%250AloadModules%252F%253C%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A17894%253A22%250AforEach%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A13691%253A11%250AloadModules%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A17878%253A5%250AloadModules%252F%253C%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A17895%253A40%250AforEach%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A13691%253A11%250AloadModules%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A17878%253A5%250AcreateInjector%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A17800%253A19%250Abootstrap%252FdoBootstrap%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A15080%253A20%250Abootstrap%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A15101%253A12%250AangularInit%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A14986%253A5%250A%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A44079%253A5%250Atrigger%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A16497%253A7%250AdefaultHandlerWrapper%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A16787%253A3%250AcreateEventHandler%252FeventHandler%2540http%253A%252F%252Flocalhost%253A8100%252Flib%252Fionic%252Fjs%252Fionic.bundle.js%253A16775%253A9%250A minErr%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13438%3A12 loadModules%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17917%3A15 forEach%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13691%3A11 loadModules%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17878%3A5 loadModules%2F<%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17895%3A40 forEach%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13691%3A11 loadModules%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17878%3A5 createInjector%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17800%3A19 bootstrap%2FdoBootstrap%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15080%3A20 bootstrap%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A15101%3A12 angularInit%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A14986%3A5 %40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A44079%3A5 trigger%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16497%3A7 defaultHandlerWrapper%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16787%3A3 createEventHandler%2FeventHandler%40http%3A%2F%2Flocalhost%3A8100%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A16775%3A9

return new ErrorConstructor(message);

ionic.bundle.js (line 13438, col 12)

do you include the file in your index.html ?? or can you show me index.html? or provide a codepen sample here’s an example which is kinda the same thing as you want: http://codepen.io/loringdodge/pen/vOrRpV

here you got

Thanks

Heyy i made it work for you :slight_smile:

study this code

Thanks really , i had to make changes into App.js And controllers.js as per your code

in app.js i had to add
angular.module(‘starter’, [‘ionic’,‘starter.controllers’])

and in controllers.js i had to add this line

angular.module(‘starter.controllers’, [])

and now it works.

thanks a lot 100 times

1 Like