2
イムangular2バージョン2.0.0-rc.5 を使用して、私は、ファイル名が角度2活字体@injectable
import {Injectable} from '@angular/core';
export interface userdetails{
userid: string,
password: string,
name: string,
sbu: string,
division: string,
position:string,
loggedin:boolean
}
@Injectable()
export class Userdetails implements userdetails {
public userid: string = null;
public password: string = null;
public name: string = null;
public sbu: string = null;
public division: string = null;
public position: string = null;
public loggedin: boolean = false;
constructor(){
}
isLoggedin(){
return this.loggedin;
}
userSBUdetails(){
return this.sbu;
}
getUserdetails(){
return {userid: this.userid,
password: this.password,
name: this.name,
sbu: this.sbu,
division: this.division,
position: this.position,
loggedin: this.loggedin};
}
resetDetails(){
this.userid = null;
this.password = null;
this.name = null;
this.sbu = null;
this.division = null;
this.position = null;
this.loggedin = false;
}
setDetails(data){
this.userid = data.userid;
this.password = null;
this.sbu = data.sbu;
this.division = data.division;
this.position = data.position;
this.loggedin = true;
}
}
と私はapp.module.tsにインポート次のステップをuserdetails.ts作成
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { routing,
appRoutingProviders } from './app.routing';
//all child route
import { DominoMenuRouting } from './domino.menu/domino.menu.routing';
import { MAPMenuRouting } from './map.menu/map.routing';
//all component
//domino.menu
import { DominoMenuComponent } from './domino.menu/domino.menu';
import { PizzaComponent } from './domino.menu/pizza/pizza';
import { ToppingComponent } from './domino.menu/topping/topping';
//map.menu
import { MAPMenuComponent } from './map.menu/map';
import { AdminUserComponent } from './map.menu/admin.user/admin.user';
import { DomUserComponent } from './map.menu/domino.user/domino.user';
import { LoginComponent } from './login/login';
import { MainMenuComponent } from './main.menu/main.menu';
import { Httpprovider } from './httpprovider';
import { Userdetails } from './userdetails/userdetails'; <<--
@NgModule({
imports: [
BrowserModule,
FormsModule,
routing,
HttpModule,
DominoMenuRouting,
MAPMenuRouting,
Userdetails <<--
],
declarations: [
AppComponent,
LoginComponent,
MainMenuComponent,
DominoMenuComponent,
PizzaComponent,
ToppingComponent,
AdminUserComponent,
DomUserComponent,
MAPMenuComponent
],
providers: [
appRoutingProviders,
Httpprovider
],
bootstrap: [ AppComponent ]
})
export class AppModule {
}
が、イムはそれを実行しているとき、私はエラーを得たが、その
VM60:18 Error: TypeError: Cannot read property 'type' of null(…)
と言うが、私はuserdetailを削除する場合アプリケーションが正常に動作しているapp.module.tsから、 null文で何か問題がありますか?
私はどのように愚かなのですか、ありがとうございました!私はそれを私の命名規則でより良くするでしょう – Rommy