Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70770

Page show error after the second attemp when i click onsubmit

$
0
0

@Fares95 wrote:

Hello , i am unable to solve that problem :
my app show the following error after i clicked for the second attem the submit button
error :


my ts file :

import { Component } from '@angular/core';
import { NavController, NavParams, ToastController, LoadingController} from 'ionic-angular';
import { Http, Headers, RequestOptions }  from '@angular/http';
import { InscriptionPage } from '../inscription/inscription';
import { EspaceCitoyenPage } from '../espace-citoyen/espace-citoyen';
import { EspaceAgentPage } from '../espace-agent/espace-agent';
import { FormBuilder, FormGroup, Validators, NgForm, FormControl,ValidatorFn,AbstractControl } from '@angular/forms';
import { PostProvider } from '../../providers/post-provider';
import { AuthService } from '../services/auth.service';

@Component({
  selector: 'page-connecter',
  templateUrl: 'connecter.html',
})
export class ConnecterPage {

  loading: any;
  private Form : FormGroup;
  cin: string = "";
  password: string= "";

  constructor(public navCtrl: NavController, private formBuilder: FormBuilder,
    public loadingCtrl: LoadingController, private postPvdr: PostProvider,
    public authService: AuthService, public http: Http, public toastCtrl: ToastController) {

      this.Form = formBuilder.group({
        cin: ['', Validators.compose([Validators.required, Validators.pattern('[0-9]*'), Validators.minLength(8), Validators.maxLength(8)])] ,
        password: ['', Validators.compose([Validators.required, Validators.minLength(6), Validators.maxLength(15) ])],
      });
      this.loading = this.loadingCtrl.create({
        cssClass: 'my-loading-class',
        spinner: 'bubbles',
        duration: 2000
      });
    }

    ionViewDidLoad()
    {
      console.log('ionViewDidLoad ConnecterPage');
    }

    addLogin()
    {
      let body =
      {
        cin: this.cin ,
        password: this.password ,
        aksi: 'add_Login'
      }

      let type = "application/json; charset= UTF-8";
      let headers = new Headers ({ 'Content-Type': type });
      let options = new RequestOptions ({ headers : headers });

      this.postPvdr.postData(body) .subscribe( (data) => {
      var alerts= data.msg;
        if(data.success){
          console.log('connexion réussie');
          this.navCtrl.push(EspaceCitoyenPage);
        }else if( data.success== false) {
          console.log('connexion échouée');
          const toast = this.toastCtrl.create({
     message: alerts ,
     duration: 2000
   });

   toast.present();
 }
  });
    }

    onSubmit(form: NgForm)
    {
      console.log (this.authService.isAuth);
      this.cin=this.Form.controls.cin.value;
      console.log (this.cin);
      this.password=this.Form.controls.password.value;
      console.log (this.password);
      this.loading.present();
      setTimeout(
        () => {
          this.addLogin();
          this.authService.signIn();
          console.log(this.authService.isAuth);
          console.log(form.value);
          this.loading.dismiss();
        }, 2000
      );
    }

  }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70770

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>