Ember.js Interview Questions – Set 02

What is the core concept of Ember.js?

Following are some concepts used in Ember.js:

Store: This is a central repository and cache of all records available in an application. Controller and admin can access it.
Models: It specifies a class which defines the data of properties and behavior.
Records: It specifies an instance of a model which contains loaded information from a server.
Adapter: It is responsible for translating requested records into the appropriate calls.
Serializer: It is used to translate JSON data into a record object.
Automatic Caching: It is used for caching.

Which steps are used to create an app in Ember.js?

You have to use the following steps to create an application in ember.js:

  • First, install an ember-cli. Almost all applications are built with ember-cli.
  • Create a new application by using ember new. It generates a new application.
  • Use materialize-CSS for styling to give a material design.
  • Create components by using ember g component.
  • Check whether there is a router.js file. It defines all your routes.
  • If you have a video route and you would like to display a set of YouTube videos on the page then create a simple video card component that iterated over and display on the video page.

What is a router in Ember.js?

A router is a core feature of Ember.js. It is used to translate the URL into the series of templates and also represent the state of an application. Every URL has a corresponding route object that controls what is visible to the user. It matches the current URL to other routes which are used for loading the data, displaying the templates and set up an application state.

What is the use of Router and {{outlet}} tag in ember.js?

A router is used to specify all the possible states of an app and map them to URLs while {{outlet}} tag is used to build a hierarchy of sections by providing a mean for a container template to include a child template.

Why is Ember.js so popular?

The best thing about Ember.js is that it develops applications which are fastest in the running in the browser.

Explain the directory structure in Ember.js.

In Ember.js, project structure is also called directory structure. It contains the following files and directories:

I-app: It contains folders and files for models, components, routes, templates, and styles.

I-bower_components/ bower.json: It is a dependency management tool which is used in Ember CLI to manage front-end plugins and component dependencies.

I-config: It contains the environment.js which controls configure settings for your app.

I-dist: It contains the created output files when we build our app for deployment.

I-node_nodules/package.json: Directory and files are from npm. Npm is the package manager for node.js.

Public: The public directory contains assets such as image and fonts.

Vendor: This directory specifies a location where front-end dependencies that are not managed by Bower go.

Tests/testem.js: Automated tests for our app go in the test folder, and testing is configured in testem.js.

Tmp: Ember CLI temporary files live here.

Ember-cli-build.js: This file describes how Ember CLI should build our app.

What is the different type of route models in Ember.js?

Dynamic Models – It provides the routes with dynamic segments. These segments are used to access the value from URL
Ember.Route.extend ({
model(parameter) {
//code block
}
});

Router.map(function() {
this.route(‘linkpage’, { path: ‘identifiers’ });
});
Multiple Models – It is used to define multiple models through RSVP.hash. For example:
Ember.Route.extend ({
model() {
return Ember.RSVP.hash({
//code block
})
}
});

What do Ember.js components specify?

The Ember.js components use the W3C web component specification and provide correct encapsulation UI widgets. It contains the three main specifications as templates, shadow DOM, and custom elements.

The components are declared within the data-template-name have a pathname instead of a plain string.

What is the role of adapters in Ember.js?

An adapter is used to handle queries related to the task assigned to it. Different adapters can be assigned different tasks. It can also query the back as well as front end. The common adapters in Ember.js are Rest, JSON, LS Adapter and the later deals with local storage or when data that needs to be stored in low.

Who was the author of Ember.js?

Ember.js was developed by Yehuda Katz and initially released on in December 2011.