October 2017
Intermediate to advanced
280 pages
6h 50m
English
In Angular, we have the same bubbling behavior we're used to in the DOM. For instance, let's suppose we have the following template:
<input-box inputPlaceholder="New todo..."
buttonLabel="Add"
(click)="handleClick($event)"
(inputText)="addTodo($event)">
</input-box>
The template declaration of the input-box component looks like this:
<input #todoInput [placeholder]="inputPlaceholder">
<button (click)="emitText(todoInput.value);
todoInput.value = '';">
{{buttonLabel}}
</button>
Once the user clicks on the button defined within the template of the input-box component, the handleClick($event) expression will be evaluated.
Further, the target property of the first argument of handleClick will be the button itself, but the currentTarget ...
Read now
Unlock full access