Angular JS Interview Question Set 3
Categories: Angular JS
How can you set, get, and clear cookies in AngularJS?
You can use:
- $cookies.put() method to set the cookies.
- $cookies.get() method to get the cookies.
- $cookies.remove to remove cookies in AngularJS.
Name the AngularJS components that can be injected as dependency
AngularJS components that can be injected as a dependency are: 1) value, 2) factory, 3) service, 4) provider, 5) constant.
What are the common Angular Global API functions
Some commonly used Angular Global API functions are:
- Angular.isString: It will return true only if the given reference is of type string.
- Angular.lowercase: It converts any string to lowercase
- Angular.uppercase: It converts any string to uppercase.
- Angular.isNumber: It returns true only if the reference is a numeric value or number.
What is BOM(Browser Object Model)?
BOM or Browser Object Model consists of history, object navigator, screen location, etc. It specifies the global browser objects like console, local storage, and window.
Explain “$rootScope” in AngularJS
“$rootScope” is a scope that is created on the DOM (Document Object Model) element.
An application can have only one $rootScope that shares, among other components. It has the ng-app directive. Other scopes are called as its child scope. It can watch expressions as well as propagate events.
What is the syntax of factory method in AngularJS?
The syntax of Factory is as follows:
app.factory(‘serviceName’,function(){ return serviceObj;})
Name different phases of the AngularJS Scope lifecycle.
Here, are different phases of AngularJS Scope lifecycle:
- Creation
- Model mutation
- Watcher registration
- Mutation observation
- Scope destruction
What is a single page application in AngularJS?
SPA or single page application is a website or web application which interacts with the users dynamically. In AngularJS, JavaScript, HTML, and CSS fit on a single page. It performs navigation without refreshing the whole HTML page.
Explain the concept of webpack
Webpack is a module bundler for Angular2 or above. It bundles, transpiles, and minifies AngularJS application.
What do you mean by NPM?
NPM stands for Node Package Manager. It consists of a command line tool client for interacting with the repository of Node.js project.
How can you create a new project in angularJS using Command Line Interface?
Once you install the Angular command-line interface, you have to run ng new project-name command in order to create a new project in Angular.