错误在[默认] new-user.component.ts:21:4提供的参数不匹配调用目标的任何签名
我正在通过angular-for-rails-developer书,并且正在'Getting Angular2-令牌注册用户'错误在[默认] new-user.component.ts:21:4提供的参数不匹配调用目标的任何签名
我的new-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 { }
新用户/新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(
'[email protected]',
'password',
'password'
);
}
}
在webstorm中,_tokenService init和registerAccount方法被列为未解决。
试试这个:
register() {
this._tokenService.registerAccount({
email: '[email protected]',
password: 'password',
passwordConfirmation: 'password'
});
}
是的,我会试试这个。它看起来像[registerAccount](https://github.com/neroniaky/angular2-token#registeraccount)的函数签名自从我编写该书的一部分(以及我的书需要更新)以来已经发生了变化。 –
谢谢!我盯着https://www.npmjs.com/package/angular2-token#signin,错过了改变。 – grouchomc
它没有帮助,您可以在这里添加您的代码? –
听起来像是你正在调用太多/很少参数的函数 – adriancarriger