我现在在Angular 5应用程序中遇到了一个奇怪的问题。下面给出了错误堆栈。
未能编译。
./src/app/registration/registration。组成部分ts模块解析失败:
保留关键字“private”(35:12),您可能需要适当的
加载程序来处理此文件类型。|};|}|构造函数(私有、,
fb,FormBuilder);|{| this.form=fb.group({@
./src/app/app。单元ts 16:0-78@/src/main。ts@多
Web包开发服务器/客户端?
http://0.0.0.0:0
./src/main。输电系统
这是我的密码。
export class RegistrationComponent implements OnInit {
form;
constructor(private fb: FormBuilder) {
this.form = fb.group({
firstName: ['', Validators.required],
lastName: ['', Validators.required],
email: ['', [Validators.required, isEmailValid('email')]],
password: ['', Validators.required],
confirmPassword: ['', Validators.required]
}, { validator: compareValidator('password', 'confirmPassword') });
}
function compareValidator(control1, control2) {
return form => {
if (form.controls[control1].value !== form.controls[control2].value) {
return { compareResult: true };
}
}
}
function isEmailValid(control) {
return control => {
var regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return regex.test(control.value) ? null : { invalidEmail: true };
}
}
ngOnInit() {
}
}
谁能帮我找出问题所在?如果您需要查看我的软件包版本,我会附上我的
包裹json
文件
{
"name": "my-angular5-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.5",
"@angular/cdk": "^5.0.0-rc0",
"@angular/common": "^5.0.5",
"@angular/compiler": "^5.0.5",
"@angular/core": "^5.0.5",
"@angular/forms": "^5.0.5",
"@angular/http": "^5.0.5",
"@angular/material": "^5.0.0-rc0",
"@angular/platform-browser": "^5.0.5",
"@angular/platform-browser-dynamic": "^5.0.5",
"@angular/router": "^5.0.5",
"core-js": "^2.5.1",
"rxjs": "^5.5.3",
"zone.js": "^0.8.18"
},
"devDependencies": {
"@angular/cli": "^1.5.5",
"@angular/compiler-cli": "^5.0.5",
"@angular/language-service": "^5.0.5",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.92",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}