Angular Interview Questions and Answers Set 5
41.What are the data bindings M angular??
Data-binding in AngularJS apps is the automatic synchronization of data between the model and view components. The way that AngularJS implements data-binding lets you treat the model as the single-source-of-truth in your application. The view is a projection of the model at all times.
42.What is Traceur compiler ?
Traceur compiler takes classes, generators, and other features from ECMAScript edition 6 (ES6) and compiles it into JavaScript ES5 that runs on the browser. This means developers can use the code from a future version that has more features and encourages design patterns
43.What is the Document Object Model?
The Document Object Model (DOM) is a programming API or object oriented representation for web documents. It represents the page and allows you to make changes. The DOM follows traditional object oriented design.
44.Explain what is Angular Expression? Explain what is key difference between angular expressions and JavaScript expressions?
Like JavaScript, Angular expressions are code snippets that are usually placed in binding such as {{ expression }}
The key difference between the JavaScript expressions and Angular expressions:-
Context : In Angular, the expressions are evaluated against a scope object, while the Javascript expressions are evaluated against the global window
Forgiving: In Angular expression evaluation is forgiving to null and undefined, while in Javascript undefined properties generates TypeError or ReferenceError
No Control Flow Statements: Loops, conditionals or exceptions cannot be used in an angular expression
Filters: To format data before displaying it you can use filters
45.What are Promises and Observables in Angular?
While both the concepts deal with Asynchronous events in Angular, Promises handle one such event at a time while observables handle a sequence of events over some time.
Promises – They emit a single value at a time. They execute immediately after creation and are not cancellable. They are Push errors to the child promises.
Observables – They are only executed when subscribed to them using the subscribe() method. They emit multiple values over a period of time. They help perform operations like forEach, filter, and retry, among others. They deliver errors to the subscribers. When the unsubscribe() method is called, the listener stops receiving further values.
ANGULAR TRAINING
Weekend / Weekday Batch
46.What is a template in Angular?
A template is a form of HTML which is a blueprint for UI. It contains attributes and elements. The template represents how to render the component. It provides a dynamic view to the end user.Also, it creates a complex view in an external HTML file.
47.What Is The Difference Between One-Way Binding And Two-Way Binding?
The main difference between one-way binding and two-way binding is as follows.
In one-way binding, the scope variable in the HTML gets initialized with the first value its model specifies.
In two-way binding, the scope variable will change its value whenever the model gets a different value
48.What is Eager and Lazy loading?
Eager loading is the default module-loading strategy. Feature modules under Eager loading are loaded before the application starts. This is typically used for small size applications.
Lazy loading dynamically loads the feature modules when there’s a demand. This makes the application faster. It is used for bigger applications where all the modules are not required at the start of the application.
49.What are directives in Angular?
Directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS to attach a specified behaviour to that DOM element or even transform the DOM element and its children. When AngularJS finds the directive at the time of rendering then it attaches the requested behaviour to the DOM element. Angular comes with a set of these directives built-in, like ngBind, ngModel, and ngClass.
50.Explain directive in Angular?
Directive are the combination of javascript code and AngularJS markup. Javascript directive code defines the behaviours and template data of HTML elements. There are some built-in directives like – “ng-controller”,”ng-app”, “ng-repeat” etc.