The app looking for a .js file but it's a .ts


#1

I’m trying to test my app on a web navigator but i’ve got an error which said that it can’t find the javascript file but it’s a typescript file.

import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { EmailValidator } from '../../validators/email';

@IonicPage()
@Component({
  selector: 'page-register',
  templateUrl: 'register.html',
})
export class RegisterPage {

  @ViewChild('signupSlider') signupSlider: any;

  firstname: FormControl;
  lastname: FormControl;
  email: FormControl;
  password: FormControl;
  passwordConf: FormControl;
  job: FormControl;

  registerForm: FormGroup;

  submitAttempt: boolean = false;


  constructor(public navCtrl: NavController, public navParams: NavParams, formBuilder: FormBuilder) {

    this.registerForm = formBuilder.group({
        firstname: ['',Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
        lastname: ['',Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
        email: ['',Validators.compose([Validators.maxLength(50),Validators.email, Validators.required]), EmailValidator.checkEmail],
        password: ['', Validators.compose([Validators.maxLength(30), Validators.required])],
        passwordConf: ['',Validators.compose([Validators.maxLength(30),, Validators.required])],
        job: ['',Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])]
    });

  }


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

  save() {

    this.submitAttempt = true;

    if(!this.registerForm.valid){
        this.signupSlider.slideTo(0);
    }
    else {
        console.log("success!")
        console.log(this.registerForm.value);
    }
  }
}


#2

You need to use the name of the class of your Validator and the name of the function to valid, like

email : ['',Validators.compose([Validators.maxLength(50), EmailValidator.checkEmail, Validators.required])]