I want to bind the value of variable to input after the ngOnInit but in my case it is binding to the default value that is initialised before.
@Component({
selector: 'myapp',
template: `{{test}} `
})
class App {
@Input() test;
}
@Component({
selector: 'parent',
directives: [App],
template: `
<myapp [test]="test"></myapp>
`
})
export class parent implements OnInit{
test:string='i dont want this value';
ngOnInit() {
this.test="I am after ngOninit";
}
}
I want "I am after ngOnInit" to be printed but in my case it is "i dont want this value" is printed. Here is the plunker code : http://plnkr.co/edit/c4wR1X740wtHaFjvuPXW?p=preview How can i achieve this. Thank you.