Ionic uses AngularJS and UI-router. It means you can use Angular services or UI-router’s state resolve to pass data from one view to another. Since Angular services are singletons, data stored in services can be accessed across other Angular controllers.
As mentioned, UI-router provides a resolve configuration. For example:
$stateProvider.state(‘todos’, {
url: ‘/todos’,
controller: ‘TestCtrl’,
templateUrl: ‘test.html’,
resolve: {
todos: function(TestService) {
return TestService.getTodos()
}
}
})
url: ‘/todos’,
controller: ‘TestCtrl’,
templateUrl: ‘test.html’,
resolve: {
todos: function(TestService) {
return TestService.getTodos()
}
}
})
No comments:
Post a Comment