我正在尝试使用IONIC 3运行应用程序,但是在运行离子服务时,出现以下错误
var ajaxReturn = "";
$.ajax({
url: "http://localhost:8080/domain/_search?q=DomainId:15&from=0&size=100",
type: 'GET',
success: function (result) {
ajaxReturn = '<div data-dojo-attach-point="dropDownNode"></div>';
},
error: function () {
console.log("Error....");
}
});
require({
cache: {
"url:local/store/dropDown.html": ajaxReturn
}
});
define("local/store/dropDown", "a, b, c, d, e, f".split(" "), function(a, b, c, d, e, f) {
a = a(d, {templateString: e});
return a
});
我尝试将'sumitAttemt'调整为'submit',但显示相同的错误。我还通过运行此命令“ ionic cordova platform add browser”添加了浏览器平台,该命令甚至已经存在,并且在执行“ ionic cordova run browser”后仍然出现相同的错误。请帮助!!!
请帮助我!
这是我的signup.ts代码
transpile started ...
[05:31:23] typescript: src/pages/signup/signup.ts, line: 68
Property 'submitAttempt' does not exist on type 'SignupPage'.
L68: this.submitAttempt = true;
[05:31:23] ionic-app-script task: "build"
[05:31:23] Error: Failed to transpile program
Error: Failed to transpile program
at new BuildError (/home/gideon/Documents/IONIC/Ecommercegd/E-commerce-ionic-app--master/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /home/gideon/Documents/IONIC/Ecommercegd/E-commerce-ionic-app--master/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
at new Promise (<anonymous>)
at transpileWorker (/home/gideon/Documents/IONIC/Ecommercegd/E-commerce-ionic-app--master/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/home/gideon/Documents/IONIC/Ecommercegd/E-commerce-ionic-app--master/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
at /home/gideon/Documents/IONIC/Ecommercegd/E-commerce-ionic-app--master/node_modules/@ionic/app-scripts/dist/build.js:109:82
at <anonymous>
[ERROR] An error occurred while running subprocess ionic-app-scripts.
ionic-app-scripts build --target cordova --platform browser exited with
exit code 1.
Re-running this command with the --verbose flag may provide more
information.
这是我的SignupPage.html代码
import { IonicPage, NavController, NavParams ,AlertController } from 'ionic-angular';
import {Http, Headers, RequestOptions} from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import { LoadingController } from 'ionic-angular';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { LoginPage } from '../login/login';
/**
* Generated class for the SignupPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-signup',
templateUrl: 'signup.html',
})
export class SignupPage {
myForm: FormGroup;
//@ViewChild("name") name;
//@ViewChild("username") username;
//@ViewChild("email") email;
//@ViewChild("password") password;
//@ViewChild("confirmpassword") confirmpassword;
constructor(public navCtrl: NavController, public navParams: NavParams,public alertCtrl: AlertController, private http: Http, public loading: LoadingController, public formBuilder: FormBuilder) {
this.myForm = this.formBuilder.group ({
name: ['', Validators.compose([Validators.minLength(5), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
username: ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z0-9 ]+'), Validators.required])],
password: ['', Validators.compose([Validators.required])],
confirmpassword: ['', Validators.compose([ Validators.required])],
email: ['', Validators.compose([Validators.email, Validators.required])],
});
}
onSubmit(myForm){
this.submitAttempt = true;
if(!this.myForm.valid){
}else{
var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json' );
let options = new RequestOptions({ headers: headers });
let data = {
password: this.myForm.value.password,
name : this.myForm.value.name,
username:this.myForm.value.username,
confirmpassword:this.myForm.value.confirmpassword,
email:this.myForm.value.email
};
let loader = this.loading.create({
content: 'Processing please wait…',
});
loader.present().then(() => {
this.http.post('http://192.168.225.39:8085/register.php',JSON.stringify(data), options)
.map(res => res.json())
.subscribe(res => {
loader.dismiss()
if(res=="Registration successfull"){
let alert = this.alertCtrl.create({
title:"whola,Done",
subTitle:("Login to continue"),
buttons: ['OK']
});
this.navCtrl.push(LoginPage);
alert.present();
}else
{
let alert = this.alertCtrl.create({
title:"oops!!",
subTitle:("Registration unsuccesfull!!"),
buttons: ['OK']
});
alert.present();
}
});
});
}
}
ionViewDidLoad() {
console.log('ionViewDidLoad SignupPage');
}
}
答案 0 :(得分:1)
您的ts文件中没有创建该属性。
因此,将其添加到您的构造函数上方,如下所示:
public submitAttempt: boolean = false;