[default] new-user.component.ts:21:4 中的错误提供的参数与调用目标的任何签名都不匹配
ERROR in [default] new-user.component.ts:21:4 Supplied parameters do not match any signature of call target
我正在阅读 angular-for-rails- 开发人员的书,现在 'Getting Angular2-Token to register a user'
我的新-user.component.ts和app.module.ts与书中的相符。关于我遗漏的任何想法?
代码如下:
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { Angular2TokenService } from 'angular2-token';
import { HomeLibraryRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NewUserComponent } from './new-user/new-user.component';
@NgModule({
declarations: [
AppComponent,
NewUserComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
HomeLibraryRoutingModule
],
providers: [Angular2TokenService],
bootstrap: [AppComponent]
})
export class AppModule { }
new-user/new-user.component.ts
import { Component, OnInit } from '@angular/core';
import { Angular2TokenService } from 'angular2-token';
@Component({
selector: 'app-new-user',
templateUrl: './new-user.component.html',
styleUrls: ['./new-user.component.css']
})
export class NewUserComponent implements OnInit {
constructor(private _tokenService: Angular2TokenService) {
this._tokenService.init({
registerAccountPath: '/api/auth'
});
}
ngOnInit() {
}
register() {
this._tokenService.registerAccount(
'test@example.com',
'password',
'password'
);
}
}
在 webstorm 中,_tokenService init 和 registerAccount 方法被列为未解决。
试试这个:
register() {
this._tokenService.registerAccount({
email: 'test@example.com',
password: 'password',
passwordConfirmation: 'password'
});
}
我正在阅读 angular-for-rails- 开发人员的书,现在 'Getting Angular2-Token to register a user'
我的新-user.component.ts和app.module.ts与书中的相符。关于我遗漏的任何想法?
代码如下: app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { Angular2TokenService } from 'angular2-token';
import { HomeLibraryRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NewUserComponent } from './new-user/new-user.component';
@NgModule({
declarations: [
AppComponent,
NewUserComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
HomeLibraryRoutingModule
],
providers: [Angular2TokenService],
bootstrap: [AppComponent]
})
export class AppModule { }
new-user/new-user.component.ts
import { Component, OnInit } from '@angular/core';
import { Angular2TokenService } from 'angular2-token';
@Component({
selector: 'app-new-user',
templateUrl: './new-user.component.html',
styleUrls: ['./new-user.component.css']
})
export class NewUserComponent implements OnInit {
constructor(private _tokenService: Angular2TokenService) {
this._tokenService.init({
registerAccountPath: '/api/auth'
});
}
ngOnInit() {
}
register() {
this._tokenService.registerAccount(
'test@example.com',
'password',
'password'
);
}
}
在 webstorm 中,_tokenService init 和 registerAccount 方法被列为未解决。
试试这个:
register() {
this._tokenService.registerAccount({
email: 'test@example.com',
password: 'password',
passwordConfirmation: 'password'
});
}