Attribute property binding

One of the great new benefits of the new Angular binding style is that you are able to more accurately target what you are binding to. Formerly, the HTML attribute that was used as a directive or data token was simply used as a matching identifier. Now, you are able to use property bindings within the binding markup for both the input and output.

Note

The code, links, and a live example of this is available at http://ngcookbook.herokuapp.com/8565/.

Getting ready

Suppose you had the following application:

[app/article.component.ts] import {Component} from '@angular/core'; @Component({ selector: 'article', template: ` <input #title (keydown)="setTitle(title.value)"> <h1>{{myTitle}}</h1> ` }) export class ArticleComponent { ...

Get Angular 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.