The binding works fine for title, subtitle, button.icon and button.name but not for button.action
parent.component.html
<app-title [title]="title" [subtitle]="subtitle" [buttons]="buttons"></app-title>
parent.component.ts
export class ParentComponent {
actionOne() {
...
}
title = 'Title';
subtitle = 'Subtitle';
buttons = [
{ 'name': 'Name1', 'icon': 'Icon1', 'action': 'actionOne()'},
{ 'name': 'Name2', 'icon': 'Icon2', 'action': 'actionTwo()'},
{ 'name': 'Name3', 'icon': 'Icon3', 'action': 'actionThree()'}
];
}
child.component.html
<section>
<div class="text-wrapper">
<h1>{{ title }}</h1>
<h2 *ngIf="subtitle">{{ subtitle }}</h2>
</div>
<template *ngIf="buttons">
<div class="buttons-wrapper">
<button *ngFor="let button of buttons" md-raised-button (click)="button.action"><md-icon *ngIf="button.icon">{{ button.icon }}</md-icon>{{ button.name }}</button>
</div>
</template>
</div>
child.component.ts
export class ChildComponent {
@Input() title:string;
@Input() subtitle:string;
@Input() buttons:string;
}