12 Essential Ionic Interview Questions *

question badge

What are the most prominent advantages and disadvantages of building applications using the Ionic framework?

answer badge

The most obvious advantages are:

  1. Ionic framework builds hybrid applications using web technologies. It means web developers can easily build mobile applications too. Also, because it uses JavaScript, almost the same codebase can be used to build both iOS and Android applications.
  2. Development cost is less compared to native iOS and Android applications.
  3. Ionic framework is excellent for quick application ideas prototyping.

Some of the disadvantages are:

  1. It is not suited for high-end graphics dependent applications or games.
  2. Performances are not as good as native applications, namely animations, scrolling, and network operations.
  3. As mentioned, JavaScript animations are not as performant as native animations. However, there are JavaScript libraries, like tweenMAX, which provide decent animation performance on the devices.
question badge

What is the difference between PhoneGap, Cordova, and Ionic?

answer badge

PhoneGap is a library that exposes native mobile phone functionalities as JavaScript API. When Adobe purchased PhoneGap, its open source core was donated to the Apache Software Foundation under the name Cordova. In the beginning, there was almost no difference between Cordova and PhoneGap. Although, over the years of development, Adobe started adding a proprietary set of the services to PhoneGap. Today, it is safe to say PhoneGap is Cordova plus extra Adobe services.

Ionic uses Cordova, not PhoneGap for its core tools. Beside native mobile phone functionalities, Ionic gives structure and code scalability to JavaScript applications by using AngularJS. It also provides a set of Angular directives and components to speed up application development.

question badge

How do you persist data between application launches using Ionic framework?

answer badge

As Ionic behind the scene builds HTML5 based applications, you can use localStorage and sessionStorage API to persist data on the mobile phone. However, since localStorage can only store strings, objects need to be stringified before saving. Also, it is important to mention localStorage has size limit around 5MB.

Find top Ionic developers today. Toptal can match you with the best engineers to finish your project.

Hire Toptal’s Ionic developers
question badge

How do you pass data from one view to another in Ionic applications?

answer badge

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.

question badge

How can you render a 5000 item list in Ionic, without affecting scroll performance?

answer badge

Ionic provides a collection-repeat directive that renders only visible items in the DOM. So even if the list is huge, like 5000 in our example, only items visible in a viewport are rendered. Thus, scroll performance is not affected.

question badge

What is the advantage of caching the views in Ionic apps? Provide examples.

answer badge

Ionic by default caches up to ten views, which improves performance and also maintains different states in the views at the same time. For example, the cache can maintain scroll position in the views or active state of buttons.

Caching can be disabled per view by using cache: false in UI-router’s state config, like in the following example:

$stateProvider.state('myState', {
   cache: false,
   url : '/myUrl',
   templateUrl : 'my-template.html'
})

Caching can be also disabled globally, by setting maxCache to 0:

$ionicConfigProvider.views.maxCache(0);
question badge

How can you detect a platform (Android or iOS) at runtime in Ionic application?

answer badge

Ionic provides platform classes: when the application is loaded, Ionic adds CSS classes to the <body> tag. For example, on iOS devices, Ionic adds platform-ios class to <body> tag. Ionic also adds OS version classes such as platform-ios8 (for iOS 8) and platform-android4_4 (for Android 4.4).

question badge

How can you access mobile phone native functionality in Ionic applications, for example the camera?

answer badge

Ionic does not provide a camera API out of the box. However, since Ionic uses plugins architecture, and because it is based on Cordova, we can use Cordova plugins in our application. Ionic team provides a set of Cordova extensions with Angular wrappers, and they can be found at ngCordova.

To use Cordova plugins, we need to install the plugin using Ionic command install <plugin name>. In some cases, we will additionally need to add the plugin’s Angular module to your Angular application too.

To use a mobile phone’s camera in the Ionic application, we can call the camera API by using cordova-plugin-camera that is hosted on GitHub. This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system’s image library.

question badge

How can you test Ionic applications?

answer badge

Ionic applications are built using AngularJS. Angular has a rich set of test libraries and frameworks such as Jasmine and Karma test runner. These frameworks can be used to write unit tests for Ionic applications. Also, ionic-CLI provides live reload feature so the application can be tested in the browser. For example, the ionic serve command can be used to load the application in any browser. Thus, we can use Chrome Developer Tools or Mozilla Firefox with Firebug to debug and inspect Ionic applications.

question badge

Performance of Ionic application is bad on older Android devices. Why is this, and what can be done to improve it?

answer badge

Ionic framework uses the default web browser available for the device to run its hybrid application. Older versions of Android devices (4.0-4.3) use Android’s default browser, which has significantly less performance and standards compliance than the modern Chrome browser.

One way to resolve this issue is to use crosswalk along with Ionic framework. Crosswalk allows you to package a modern Chrome webview along with Ionic application, so an application does not have to rely on native Android browser. The end results are much better performances and modern web API across all Android versions.

question badge

What’s the difference between “ionic build” and “ionic prepare”?

answer badge

ionic prepare <platform> copies all files from the www folder into the target platform’s www folder.

ionic build <platform> also does this, but also builds the app’s source code so that it can be run on a simulator/emulator or a device.

question badge

In broad terms, how do you deploy an Ionic project onto a device?

answer badge

To run your app, all you have to do is enable USB Debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line.

* There is more to interviewing than tricky technical questions, so these are intended merely as a guide. Not every “A” candidate worth hiring will be able to answer them all, nor does answering them all guarantee an “A” candidate. At the end of the day, hiring remains an art, a science — and a lot of work.
Submit an interview question
Submitted questions and answers are subject to review and editing, and may or may not be selected for posting, at the sole discretion of Toptal, LLC.
All fields are required
Thanks for submitting your question.
Our editorial staff will review it shortly. Please note that submitted questions and answers are subject to review and editing, and may or may not be selected for posting, at the sole discretion of Toptal, LLC.
Looking for Ionic experts? Check out Toptal’s Ionic developers.