Advertisement
reqtrex

Untitled

Jan 22nd, 2020
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     addFlashcards(){
  2.  
  3.         this.testService.addTest(this.createTest()).subscribe(result => {
  4.             this.editTest = result;
  5.             console.log(result);
  6.         }, error => console.error(error))
  7.  
  8.  
  9.         let isPossible: boolean = true;
  10.         let i: number = 0;
  11.         this.wordsW.forEach(element => {
  12.             if(element == "") isPossible = false;
  13.             if(this.translatedWords[i] == "") isPossible = false;
  14.             if(this.sentence[i] == "") isPossible = false;
  15.             if(this.translatedSentence[i] == "") isPossible = false;
  16.             i++;
  17.         });
  18.         if(isPossible){
  19.             console.log(this.editTest.Id)
  20.             this.testService.addFlashcards(this.createFlashcards(this.editTest.Id)).subscribe(result => {
  21.                 console.log(result.toString())
  22.                 this.messageService.success("Created new flashcards");
  23.                 this.router.navigateByUrl('/tests/add', { skipLocationChange: true }).then(() => {
  24.                     this.router.navigate(['/tests/add']);
  25.                 });
  26.             }, error => console.error(error));
  27.         } else {
  28.             this.messageService.error("Invalid form");
  29.         }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement