How to display a component input property in view?
I've tried several ways, including this, but none has been working: https://ngdev.space/angular-2-input-property-changes-detection-3ccbf7e366d2
Component usage:
<card [title]='My Awesome Card'></card>
Template:
<div class="ui card">
<div class="content">
<div class="header">{{ title }}</div>
</div>
</div>
Part of component declaration:
@Component({
selector: 'card',
templateUrl: './card.component.html'
})
export class CardComponent implements OnInit {
private _title: string;
get title(): string {
return this._title;
}
@Input()
set title(title: string) {
console.log('prev value: ', this._title);
console.log('got title: ', title);
this._title = title;
}
...