Blank project didn't call controller


#1

Hello,

I started ionic project using “ionic start app blank”

but when I run it the initial controller isn’t called. I put console.log(“test”) in LoginCtrl controller, but didn’t work.

controller.js:
angular.module('starter.controllers', []) .controller('AppCtrl', function($scope) { console.log("test"); });

app.js
` angular.module(‘starter’, [‘ionic’, ‘starter.controllers’])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state(‘app’, {
url: ‘/app’,
abstract: true,
templateUrl: ‘templates/system.html’,
controller: ‘AppCtrl’
})

$urlRouterProvider.otherwise('/app');

});`

I tried $urlRouterProvider.otherwise(’/’); too


#2

Did you add: <script src="js/controllers.js"></script> in index.html?


#3

yes…

<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/controllers.js"></script>
<script src="js/app.js"></script>
<ion-pane>
  <ion-header-bar class="bar-stable">
    <h1 class="title">Ionic Blank Starter</h1>
  </ion-header-bar>
  <ion-content>
  </ion-content>
</ion-pane>

#4

I tried this:

<script src="js/app.js"></script>
<script src="js/controllers.js"></script>

but without success