I encountered an issue while attempting to set up simple navigation in my ionic application. The error message I received was: "Argument 'LoginCtrl' is not a function, got undefined in the Ionic. What could be causing this problem?"
Here is a snippet of my index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<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>
<script src="lib/angular-route.js"></script>
<script src="lib/angular-cookies.js"></script>
<script src="lib/ng-cordova/dist/ng-cordova.min.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/restService/login.js"></script>
</head>
<body ng-app="starter">
<ion-nav-view></ion-nav-view>
</body>
</html>
In my app.js file:
angular.module('starter', ['ionic',
'Authentication',
'ngCookies'])
.config(function($stateProvider, $urlRouterProvider) {
//$urlRouterProvider.otherwise('views/main')
$stateProvider.state('login', {
url: '/login',
controller: 'LoginCtrl',
templateUrl: 'views/throbber.html'
})
})
.run(['$ionicPlatform', '$rootScope', '$location', '$cookieStore', '$http',
function($ionicPlatform, $rootScope, $location, $cookieStore, $http) {
$ionicPlatform.ready(function() {
try {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
} catch (ex) {
alert(ex);
}
});
}]);
angular.module('Authentication', []);
My login.js file:
angular.module('Authentication')
.controller('LoginCtrl' [
function () {
alert('test');
}
]);
The contents of throbber.html:
<div>THROBBER</div>