onEnter callback on $stateProvider


#1

Hi,

I need to trigger a function to prepare a google map to centre on my current location before rendering the view.

The onEnter callback on the $stateProvider seems to be what I need but I’m getting syntax errors in my IDE (intellij) and nothing is rendering in the app itself.

I don’t load ui-router as a dependency, I only load ionic. The $stateProvider has been working as normal up to this point so now I’m just wondering if Ionic implements or wraps onEnter and onExit callbacks?

'use strict';

angular.module('myApp', ['ionic'])

.config(function($stateProvider) {
    $stateProvider
        .state('index', {
            url: '/',
            templateUrl: 'index.html'
        })
        .state('destination', {
            url: '/destination',
            templateUrl: 'partials/destination.html'
        }, 
	    onEnter: function() {
	    console.log("Where in the onEnter callback")
        })           
        .state('summary', {
            url: '/summary',
            templateUrl: 'partials/summary.html'
        });
});