[SOLVED] Controller doesn't call function on loading


#1

Hi all,

maybe someone know why my function dosn’t fire at first time. It fires only if i change my route to another page and back to the first page.

My Route-Settings:

$stateProvider
//APP
.state('app', {
url: '/app',
cache: false,
abstract: true,
templateUrl: 'templates/app.html',
controller: 'appCtrl',
})
.state('app.home', {
url: '/home/:id',
cache: false,
views: {
'appContent': {
templateUrl: 'templates/app/home.html',
controller: 'appHomeCtrl',
},
},
})

My appHomeCtrl (the “test”-Altert works fine at the initial loading. The myCall works only if i call the route again.

alert('test');

var myCall = myService.myCall().then(
 function (success) {
  alert(success);
 },
 function (error) {
  alert(error);
 }
);