Angular2, view not updating after variable changes in settimeout

后端 未结 4 1201
再見小時候
再見小時候 2021-01-17 07:47

I am trying to setup my first angular2 application as an experiment and am using the latest beta release.

I am facing a weird issue where the variable i am using in

4条回答
  •  温柔的废话
    2021-01-17 08:22

    That should work. Do you have any other errors in console?

    @Component({
     selector: 'my-app',
     template: `

    Hello {{title}}

    ` }) export class App { public title: string = "World"; constructor() { setTimeout(() => { this.title = "Brave New World" }, 1000);) } }

    Look at this Plunker: http://plnkr.co/edit/XaL4GoqFd9aisOYIhuXq?p=preview

提交回复
热议问题