Why is the component in this simple plunk
@Component({
selector: \'my-app\',
template: `I\'m {{message}} `,
})
export class App {
You just have to update your message in the right lifecycle hook, in this case is ngAfterContentChecked
instead of ngAfterViewInit
, because in ngAfterViewInit a check for the variable message has been started but is not yet ended.
see: https://angular.io/docs/ts/latest/guide/lifecycle-hooks.html#!#afterview
so the code will be just:
import { Component } from 'angular2/core'
@Component({
selector: 'my-app',
template: `I'm {{message}} `,
})
export class App {
message: string = 'loading :(';
ngAfterContentChecked() {
this.message = 'all done loading :)'
}
}
see the working demo on Plunker.