Reputation: 649
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?
Upvotes: 6
Views: 1582
Reputation: 8156
Use this, This worked fine for me.
import { Observable } from 'rxjs/Observable';
Observable.interval(500)
.subscribe(() => {
this.test = new Date().getMilliseconds().toString();
})
Upvotes: 2
Reputation: 649
I know this sounds crazy, but the moment I comment out
<script src="https://use.fontawesome.com/f0298bc7e9.js"></script>
in my index.html everything works. I don't know why or how...
It just seems to be the reason for that. With the line: Strange behavior. Without: Everything works.
To make it even more strange: I cannot reproduce that on the "official" plunker...
Upvotes: 0