5 avg. rating (100% score) - 5884 votes
Wish to be an Angular or Angular 2 web developer? Confused where and what to start? Here we’re, wisdomjobs assisting you with all necessary information from learning Angular 2 to getting well knowledged using our tutorials and preparing an eye catchy winning resume with our samples and templates. Angular being the best type-script based open source front end web application which helps in making easy web applications while freeing developers from many challenges faced otherwise, thus increasing the number of developers working on it and there by the competition. But by going through our Angular 2 job interview questions and answers page that has well assorted range of Q&A you can easily crack any Angular 2 jobs interview and get into a winning position.
Angular 2 is written entirely in Typescript and meets the ECMAScript 6 specification :
Angular 2 is not just a typical upgrade but a totally new development. The whole framework is rewritten from the ground. Angular 2 got rid of many things like $scope, controllers, DDO, jqLite, angular.module etc.
It uses components for almost everything. Imagine that even the whole app is now a component. Also it takes advantage of ES6 / TypeScript syntax. Developing Angular 2 apps in TypeScript has made it even more powerful.
Apart from that, many things have evolved and re-designed like the template engine and many more.
Same can be written using TypeScript as follows-
public name : string = "";
public id : string = "";
@NgModule is a decorator function. A decorator function allows users to mark something as Angular 2 thing (could be a module or component or something else) and it enables you to provide additional data that determines how this Angular 2 thing will be processed, instantiated and used at the runtime. So, whenever user writes @NgModule, it tells the Angular 2 module, what’s going to be included and used in and using this module.
In Angular, a Component is a special kind of directive that uses a simpler configuration which is suitable for a component-based application structure.
@Input allows you to pass data into your controller and templates through html and defining custom properties. This allows you to easily reuse components and have them display different values for each instance of the renderer.
Components push out events using a combination of an @Output and an EventEmitter. This allows a clean separation between reusable Components and application logic.
PrimeNG is a collection of rich UI components for Angular 2. PrimeNG is a sibling of the popular JavaServer Faces Component Suite, PrimeFaces. All widgets are open source and free to use under Apache License 2.0, a commercial friendly license. PrimeNG is developed by PrimeTek Informatics, a company with years of expertise in developing open source UI components. AngularJS makes it possible to use predefined components for development like tables etc. This helps developers save time and efforts. Using PrimeNG developers can create awesome applications in no time
Angular 2 is built for speed :
Each component is comprised of a template, which is the HTML for the user interface. Add to that a class for the code associated with a view. The class contains the properties and methods, which perform actions for the view,A component also has metadata, which provides additional information about the component to Angular.
ECMAScript, or ES.
Setting up our development environment for Angular 2 requires two basic steps:
Just like any other client side or web application, angular 2 application should also follow some of the basic guidelines to mitigate the security risks. Some of them are:
Angular 2 is a platform not only a language:
Routing is a mechanism which enables user to navigate between views/components. Angular 2 simplifies the routing and provide flexibility to configure and define at module level (Lazy loading).
The angular application has single instance of the Router service and whenever URL changes, corresponding Route is matched from the routing configuration array. On successful match, it applies redirects and the router builds a tree of ActivatedRoute objects and contains the current state of the router. Before redirection, the router will check whether new state is permitted by running guards (CanActivate). Route Guards is simply an interface method that router runs to check the route authorization. After guard runs, it will resolve the route data and activate the router state by instantiation the required components into <router-outlet> </router-outlet>.
Angular 2 doesn’t have bi-directional digest cycle, unlike angular 1. In angular 2, any change occurred in the component always gets propagated from the current component to all its children in hierarchy. If the change from one component needs to be reflected to any of its parent component in hierarchy, we can emit the event by using Event Emitter api.
In short, EventEmitter is class defined in @angular/core module which can be used by components and directives to emit custom events.
@output() somethingChanged = new EventEmitter();
We use somethingChanged.emit(value) method to emit the event. This is usually done in setter when the value is being changed in the class.
This event emit can be subscribed by any component of the module by using subscribe method.
myObj.somethingChanged.subscribe(val) => this.myLocalMethod(val));
All enterprise applications follows a set of coding conventions and guidelines to maintain code in better way. Codelyzer is an open source tool to run and check whether the pre-defined coding guidelines has been followed or not. Codelyzer does only static code analysis for angular and typescript project.
Codelyzer runs on top of tslint and its coding conventions are usually defined in tslint.json file. Codelyzer can be run via angular cli or npm directly. Editors like Visual Studio Code and Atom also supports codelyzer just by doing a basic settings.
To set up the codelyzer in Visual Studio code, we can go to File -> Preferences -> User Settings and add the path for tslint rules.
Hide Copy Code
To run from cli: ng lint.
To run from npm: npm run lint
ell, optimization depends on the type and size of application and many other factors. But in general, I would consider the following points while optimizing the angular 2 app:
Well, in most of the cases, the 3rd party library comes with its own .d.ts file for its type definition. In some cases, we need to extend the existing type by providing some more properties to it or if we need to define additional types to avoid Typescript warning.
If we need to extend the type definition for external library, as a good practice, we should not touch the node_modules or existing typings folder. We can create a new folder, say “custom-typings” and keep all customized type definition in that.
For those cases, we can define or extend the types by creating our own “.d.ts” file.
Since shadow DOM are static in nature, it’s a good candidate to be cached as it is not accessible to developer. The cached DOM would be rendered faster in the browser providing better performance. Moreover, shadow DOM can be managed comparatively well while detecting the change in angular 2 application and re-paint of view can be managed efficiently.
Promises vs Observables :
Differences - Constructor Vs. ngOnInit
Angular 2 Constructors:-
Angular 2 ngOnInit:-
Angular 2 Related Tutorials
|PHP Tutorial||Ext JS Tutorial|
|Django Tutorial||Angular Material Tutorial|
|Phonegap Tutorial||MongoDB Tutorial|
Angular 2 Related Interview Questions
|PHP Interview Questions||Angular JS Interview Questions|
|Ext JS Interview Questions||Django Interview Questions|
|Java Abstraction Interview Questions||Angular Material Interview Questions|
|Phonegap Interview Questions||MongoDB Interview Questions|
|Angular 5 Interview Questions||Angular 4 Interview Questions|
|Angular 6 Interview Questions||Angular 7 Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.