By emles


2018-10-11 14:12:32 8 Comments

I am new to Angular(6). I am using setInterval function in a component. It is working but when I navigate to another route, setInterval continues to execute. Please help me to identify the reason.

//Calling it in ngOnit()
autosavedraftsolution() {
      setInterval(() => {
        console.log(this.draftSolutionForm);
        if (this.solutionTitleValid) {
          this.savedraftsolution();
        }
      }, this.autoSaveInterval);
    }

//savedraftsolution()
  savedraftsolution() {
    console.log("saving..");

    this.connectService.saveDraftSolution({
      Title: this.draftSolutionForm.get('Title').value,
      Product: this.draftSolutionForm.get('Product').value
    } as Draftsolution).subscribe(draftsol => {
      console.log("saved");

    });
  }

It keeps on showing me "saving.." and "saved" message in console.

Related Questions

Sponsored Content

25 Answered Questions

[SOLVED] In Node.js, how do I "include" functions from my other files?

3 Answered Questions

[SOLVED] Pass data from one component to another in angular 6

  • 2019-03-30 03:55:45
  • sooraj s pillai
  • 371 View
  • 1 Score
  • 3 Answer
  • Tags:   angular angular6

13 Answered Questions

[SOLVED] Execute the setInterval function without delay the first time

14 Answered Questions

[SOLVED] Pass parameters in setInterval function

3 Answered Questions

[SOLVED] value is undefined when passed in component in angular 6

7 Answered Questions

[SOLVED] @Directive v/s @Component in Angular

3 Answered Questions

[SOLVED] angular http fetching every time i navigate to component using routing

2 Answered Questions

1 Answered Questions

Angular view is not updated with default Javascript setInterval function

2 Answered Questions

[SOLVED] Angular 2 passing data to another component

  • 2016-03-15 05:23:16
  • Abhijeet Bajracharya
  • 509 View
  • 1 Score
  • 2 Answer
  • Tags:   javascript angular

Sponsored Content