0

I have made an ionic app but the controller execute twice.

My Stateprovider

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

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

    .state('step1', {
        url: '/step1/',
        templateUrl: '/templates/step1.html',
        controller: 'Step1Ctrl'
    })
$urlRouterProvider.otherwise('/');
});

My Controllers:

    .controller('LoginCtrl', function ($scope, $state, $stateParams, $http, $rootScope, $timeout ) {}
    .controller('Step1Ctrl', function ($scope, $state, $stateParams, $http, $rootScope, $timeout ) {
//This Code execute twice
$scope.$on('$ionicParentView.beforeEnter', function () {
promise1 = $timeout(function () { $state.go('index'); }, 30000);
})
};

My index:

<body ng-app="starter">
      <ion-nav-view></ion-nav-view>
  </body>

I have search for days now and nothing works. Can you help me?

I edit my code and inside the controller I put the timeout that execute twice

Dimitris
  • 113
  • 1
  • 11

0 Answers0