How to use {}, [], [] and [()] in template using Angular2?
All these symbols such as {}, [], [] and [()] are used to express data, event binding, templating concerns and property binding. {} is used for interpolation
[] is used of property binding
[()] is used for event binding
Use of {} symbol
import {Component} from 'Angular2/core';
@Component({
selector: 'cars-app',
template: `
<h1>BMW</h1>
<h2>Total {{ totalCars }}</h2>
` }) export class CarsApp {
totalCars: number = 985;
}
use of [] symbol
Through special attributes on HTML elements, Every DOM property can be written.
Use of [()] symbol
The common syntax of event binding attribute is— ([Name of DOM event]) =”[Template expression]”
BY Best Interview Question ON 07 Jan 2022