Category: 3. Angular 8
-
Forms
Angular forms are used to handle user’s input. We can use Angular form in our application to enable users to log in, to update profile, to enter information, and to perform many other data-entry tasks. In Angular 8, there are 2 approaches to handle user’s input through forms: Both approaches are used to collect user…
-
Two way Data Binding in Angular 8
We have seen that in one-way data binding any change in the template (view) were not be reflected in the component TypeScript code. To resolve this problem, Angular provides two-way data binding. The two-way binding has a feature to update data from component to view and vice-versa. In two-way databinding, automatic synchronization of data happens…
-
Event Binding in Angular 8
In Angular 8, event binding is used to handle the events raised from the DOM like button click, mouse move etc. When the DOM event happens (eg. click, change, keyup), it calls the specified method in the component. In the following example, the cookBacon() method from the component is called when the button is clicked:…
-
String Interpolation in Angular 8
String Interpolation is a one-way databinding technique which is used to output the data from a TypeScript code to HTML template (view). It uses the template expression in double curly braces to display the data from the component to the view. String interpolation adds the value of a property from the component. For example: We have already created an…
-
Property Binding in Angular 8
Property Binding is also a one-way data binding technique. In property binding, we bind a property of a DOM element to a field which is a defined property in our component TypeScript code. Actually Angular internally converts string interpolation into property binding. For example: Property binding is preferred over string interpolation because it has shorter and cleaner…
-
Data Binding in Angular 8
Data binding is the core concept of Angular 8 and used to define the communication between a component and the DOM. It is a technique to link your data to your view layer. In simple words, you can say that data binding is a communication between your typescript code of your component and your template…
-
ngSwitch Directive
In Angular 8, ngSwitch is a structural directive which is used to Add/Remove DOM Element. It is similar to switch statement of C#. The ngSwitch directive is applied to the container element with a switch expression. Syntax of ngSwitch ngSwitchCase In Angular ngSwitchCase directive, the inner elements are placed inside the container element. The ngSwitchCase…
-
*ngFor Directive
The *ngFor directive is used to repeat a portion of HTML template once per each item from an iterable list (Collection). The ngFor is an Angular structural directive and is similar to ngRepeat in AngularJS. Some local variables like Index, First, Last, odd and even are exported by *ngFor directive. Syntax of ngFor See the…
-
ngIf Directive
The ngIf Directives is used to add or remove HTML Elements according to the expression. The expression must return a Boolean value. If the expression is false then the element is removed, otherwise element is inserted. It is similar to the ng-if directive of AngularJS. ngIf Syntax The *ngIf directive form with an “else” block…
-
Directives
The Angular 8 directives are used to manipulate the DOM. By using Angular directives, you can change the appearance, behavior or a layout of a DOM element. It also helps you to extend HTML. Angular 8 directives can be classified in 3 categories based on how they behave: Component Directives: Component directives are used in main…