我得到HomeComponent的角度打击错误
Uncaught Error: Can't resolve all parameters for HomeComponent: (?, ?, ?, ?, ?).
at syntaxError (compiler.js:486)
at CompileMetadataResolver._getDependenciesMetadata (compiler.js:15706)
at CompileMetadataResolver._getTypeMetadata (compiler.js:15541)
at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (compiler.js:15026)
at CompileMetadataResolver.loadDirectiveMetadata (compiler.js:14880)
at eval (compiler.js:34420)
at Array.forEach (<anonymous>)
at eval (compiler.js:34419)
at Array.forEach (<anonymous>)
at JitCompiler._loadModules (compiler.js:34416)
HomeComponent.ts
import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {FormBuilder} from '@angular/forms';
import {endpointLocation} from '../endpoint';
import {SimpleGlobal} from 'ng2-simple-global';
import {Headers, Http, Request, RequestMethod, RequestOptions} from '@angular/http';
import {AuthHttp} from 'angular2-jwt';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css'],
providers: []
})
export class HomeComponent implements OnInit {
email: string;
endpoints: string;
msg: string;
title: string;
mailVerificationCode: string;
message: string;
answer: string;
cnfPassword: string;
password: string;
showResetPassword: boolean;
showLoginButton = 'none';
// title: string;
alertStatus: string;
loginStatus: boolean;
username: string;
constructor(private formBuilder: FormBuilder,
private route: Router, private sg: SimpleGlobal, private _http: Http, private authHttp: AuthHttp) {
this.endpoints = endpointLocation.EXCHANGE;
if (localStorage.getItem('kryptoexlogin') === 'true') {
this.loginStatus = true;
} else {
this.loginStatus = false;
}
this.username = localStorage.getItem('kryptoexusername');
}
ngOnInit() {
let server = location.href;
if (server.indexOf('verification_token') !== -1) {
let param = server.split('?');
if (param[1].indexOf('verification_token') !== -1) {
let token = param[1].split('=');
this.mailVerificationCode = token[1];
if (this.mailVerificationCode.length !== 0) {
this.title = 'Email Verification';
this.verifyEmail();
} else {
this.alertStatus = 'alert-warning';
}
}
} else if (server.indexOf('ipauth_token') !== -1) {
let param = server.split('?');
if (param[1].indexOf('ipauth_token') !== -1) {
let token = param[1].split('=');
this.mailVerificationCode = token[1];
if (this.mailVerificationCode.length !== 0) {
this.title = 'Ip Authentication';
this.verifyIpAuth();
} else {
this.alertStatus = 'alert-warning';
}
}
} else if (server.indexOf('reset_token') !== -1) {
let param = server.split('?');
if (param[1].indexOf('reset_token') !== -1) {
let token = param[1].split('=');
this.mailVerificationCode = token[1];
if (this.mailVerificationCode.length !== 0) {
this.title = 'Reset Password';
this.showResetPassword = true;
} else {
this.alertStatus = 'alert-warning';
}
}
} else if (server.indexOf('disable_2fa') !== -1) {
let param = server.split('?');
if (param[1].indexOf('disable_2fa') !== -1) {
let token = param[1].split('=');
this.mailVerificationCode = token[1];
if (this.mailVerificationCode.length !== 0) {
this.title = 'Disabling Two Factor Authentication';
this.dsiable2FA();
} else {
this.alertStatus = 'alert-warning';
}
}
}
}
setResetPassword() {
if ((this.answer !== null || this.answer !== '' || this.answer !== undefined) && (this.password === null || this.password === '' || this.password === undefined)) {
this.password = this.answer;
this.answer = '';
} else if (this.password !== null || this.password !== '' || this.password !== undefined) {
if (this.answer !== null || this.answer !== '' || this.answer !== undefined) {
this.cnfPassword = this.answer;
this.answer = '';
this.resetPassword();
}
}
}
verifyEmail() {
this.msg = 'Your account is being validated, please wait....';
let url = this.endpoints.concat('user/verify/email/' + this.mailVerificationCode + '/');
this.httGet(url).subscribe(
data => {
this.msg = data.msg;
if (data.status) {
this.alertStatus = 'alert-success';
this.showLoginButton = 'block';
} else {
this.alertStatus = 'alert-danger';
}
}, erorr => {
this.alertStatus = 'alert-warning';
this.msg = 'Problem in verifying your mail, please try again later...';
}, () => console.log('finished verifying mail')
);
}
resetPassword() {
if (this.password === this.cnfPassword) {
this.msg = 'Resetting your password...';
let param = {
'password': this.password
};
let url = this.endpoints.concat('user/reset_password_link/validate/' + this.mailVerificationCode + '/');
this.httPost(param, url).subscribe(
data => {
this.msg = data.msg;
if (data.status) {
this.alertStatus = 'alert-success';
this.showLoginButton = 'block';
} else {
this.alertStatus = 'alert-danger';
}
}, erorr => {
this.alertStatus = 'alert-warning';
this.msg = 'Problem in verifying your mail, please try again later...';
}, () => console.log('finished verifying mail')
);
} else {
this.msg = 'Passwords does not match';
}
}
verifyIpAuth() {
this.msg = 'Your IP is being authenticated, please wait....';
let url = this.endpoints.concat('user/validate_ipauth_access/' + this.mailVerificationCode);
this.httGet(url).subscribe(
data => {
this.msg = data.msg;
if (data.status) {
this.alertStatus = 'alert-success';
this.showLoginButton = 'block';
} else {
this.alertStatus = 'alert-danger';
}
}, erorr => {
this.msg = 'Problem in authenticating IP access, please try again later...';
}, () => console.log('finished authenticating IP access')
);
}
dsiable2FA() {
this.msg = '2FA is being disabled, please wait...';
let url = this.endpoints.concat('verification/disable/token/2fa/' + this.mailVerificationCode);
this.httGet(url).subscribe(
data => {
this.msg = data.msg;
if (data.status) {
this.alertStatus = 'alert-success';
this.showLoginButton = 'block';
} else {
this.alertStatus = 'alert-danger';
}
}, erorr => {
this.msg = 'Problem in disabling 2fa';
}, () => console.log('finished disabling 2fa')
);
}
reset() {
this.msg = null;
this.password = null;
}
resetForm() {
this.reset();
}
/*http service methods*/
httGet(url: string) {
return this._http.get(url)
.map(res => res.json());
}
httDelete(url: string) {
return this._http.delete(url)
.map(res => res.json());
}
httPost(param: any, url: string) {
var headers = new Headers({
'Content-Type': 'application/json'
});
var requestOptions = new RequestOptions({
method: RequestMethod.Post,
url: url,
headers: headers,
body: param
});
return this._http.request(new Request(requestOptions))
.map(res => res.json());
}
httpGetAuth(url: string) {
let headers = new Headers();
headers.append('Authorization', localStorage.getItem('kryptoextoken'));
let options = new RequestOptions({headers: headers});
return this._http.get(url, {headers: headers})
.map(res => res.json());
}
httpPostAuth(param: any, url: string) {
let headers = new Headers();
headers.append('Authorization', localStorage.getItem('kryptoextoken'));
var requestOptions = new RequestOptions({
method: RequestMethod.Post,
url: url,
headers: headers,
body: param
});
return this._http.request(new Request(requestOptions))
.map(res => res.json());
}
}
上面是我的HomeComponent.ts文件,请让我知道我想念的地方。 我只是使用Http,Router。相同的文件在Angular 6中有效,但在Angular 5中无效,我需要在angular 5中进行处理,因为我使用的Tradviewchart仅在Angular 5中有效