I am using Angular2 RC5 - and I have a strange problem. In my main component I use for testing purposes in my constructor:
setInterval(() => {
this.test = new Date().getMilliseconds().toString();
}, 500);
Binding in my template is
<p>{{test}}</p>
Upon loading or reloading the page it either displays a value (but does not change on further ticks), somtimes it works as intended (updates value on every tick), and sometimes just displays the initial value and does not change at all. Seems random.
I get crazy over this, as it seems in the official plunker version it works without a problem. (Edit: Plunker link )
I get the same behaviour when using this code in other components aswell..
Anyone any idea?
Use this, This worked fine for me.
import { Observable } from 'rxjs/Observable';
Observable.interval(500)
.subscribe(() => {
this.test = new Date().getMilliseconds().toString();
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With