ALERT: Newbie to Angular2 I have the following code:
@Component({
selector: 'my-app',
template: `<h1>Hello {{name}}</h1>
<button (click)="ClickMe()">Button</button>`
})
export class AppComponent
{
name:string;
ClickMe(event : event) :void {
var source = new Observable((observer: any) => {
observer.next(42);
});
source.subscribe(function (x : any) {
name = x;
alert(x);
});
}
}
my alert does pops up, but the view doesnt change in other words, I don't get the "Hello 42" , I still see just "Hello"
This should work: