Marilou Marilou - 2 months ago 9
TypeScript Question

How can I delay an event from happening with AngularJS / Javascript?

Here is what I have tried but it seems there is something wrong as it shows a syntax error on the ) after 5000

self.$timeout(() => {
self.phrases.forEach((phrase: IPhraseRow) => {
if (phrase.phraseId != phraseId) {
phrase.current = false;
}
});
}), 5000);


Am I going about this in the right way. I want the forEach to be delayed from executing for 5 seconds.

Answer
self.$timeout(() => {
    self.phrases.forEach((phrase: IPhraseRow) => {
        if (phrase.phraseId != phraseId) {
            phrase.current = false;
        }
    });
}, 5000);

You have one too many ) before the 5000.

}, 5000);

Instead of

}), 5000);