What are the chief components of Angular IO?
The main components are:
Component- Brings the modules together
Metadata- Adds more data to the Angular JS class
Modules- Breaks up the application into logical pieces of code, each module performing a single task
Service- Creates a component that can be shared across the whole application
Templates- Defines an Angular application’s views
Name the three Module Arrays
- Bootstrap array – Tells Angular which components to load so the functionality can be accessed
- Export array – Sends out components, directives, and pipes to be used in other modules.
- Import array – Brings in functionality from other Angular modules
What’s an Angular 2 directive?
A directive is a custom HTML element that is used to extend the power of HTML. Angular 2 has the following directives that get called as part of the BrowserModule module.
- ngIf −The ngif element is used to add elements to the HTML code if it evaluates to true, else it will not add the elements to the HTML code.Syntax*ngIf = ‘expression’ If the expression evaluates to true then the corresponding gets added, else the elements are not added.
- ngFor −The ngFor element is used to elements based on the condition of the For loop.Syntax*ngFor = ‘let variable of variablelist’ The variable is a temporary variable to display the values in the variablelist.
What is Dependency Injection?
Dependency injection is the ability to add the functionality of components at runtime. Let’s take a look at an example and the steps used to implement dependency injection.
What’s a Pipe?
Pipes edit, transform and format the data within the template. Bottom line, pipes takes input data and transforms it into output into something that we want.
What is the AOT compilation, and what are its pros and cons?
AOT is an acronym for Ahead of Time. Rather than being compiled in the browser at runtime, components and templates are compiled at build time, they are converted to native JavaScript and HTML.
On the plus side, AOT offers faster download and rendering times. Furthermore, build time errors are more easily detected.
On the minus side, AOT creates large JavaScript bundles once compilation is done, which runs counter to what AOT is there for in the first place. Furthermore, AOT only works with HTML and CSS. Lastly, it requires a clean-up step.
What is the difference between structural directive and attribute directive in Angular 7?
Structural directives are used to alter the DOM layout by removing and adding DOM elements. These directives are far better in changing the structure of the view. Examples of Structural directives are NgFor and Nglf.
Attribute Directives are used as characteristics of elements. For example, a directive such as built-in NgStyle in the template Syntax guide is an attribute directive.
What is the difference among “declarations”, “providers” and “import” in NgModule?
Declarations are used to make directives (including components and pipes) from the current module available to other directives in the current module. Selectors of directives, components or pipes are only matched against the HTML if they are declared or imported.
providers are used to make services and values known to DI. They are added to the root scope and they are injected to other services or directives that have them as dependency. A special case for providers is lazy loaded modules that get their own child injector. Providers of a lazy loaded module are only provided to this lazy loaded module by default (not the whole application as it is with other modules).
import makes the exported declarations of other modules available in the current module.
Leave a Reply