Hybrid Application Developer Question:
Download Questions PDF

Explain me how do you pass data from one view to another in Ionic applications?

Answer:

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: 'TodosCtrl',
templateUrl: 'todos.html',
resolve: {
todos: function(TodosService) {
return TodosService.getTodos()
}
}
})
One advantage of resolve over stateful services is better testing: as resolve injects dependencies in the controller, it is easy to test them.

Download Hybrid Application Developer Interview Questions And Answers PDF

Previous QuestionNext Question
As you know performance of Ionic application is bad on older Android devices. Why is this, and what can be done to improve it?Explain me what are the most prominent advantages and disadvantages of building applications using the Ionic framework?