0
我是angularJs2的新手。我的要求是我想在單個組件中使用多個模板。就像我有ForgetPasswordComponent
,有兩條路線名稱爲forgot-password
和password/reset
。所以我想在diff路線上調用diff-diff模板。目前forgot-password.component.html
正在呼叫forgot-password
路線,現在我想調用差異。模板password/reset
路線。 這是我的代碼。如何使用angular2調用單個組件中的多個模板
APP-routing.module.ts
{ path: 'forgot-password', component: ForgetPasswordComponent },
{ path: 'password/reset', component: ForgetPasswordComponent },
勿忘password.component.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AlertService, AuthenticationService, ForgotpasswordService } from '../_services/index';
//import { AppSettings,IEnvVars } from '../_configs/app.settings';
@Component({
moduleId: module.id,
templateUrl: '../templates/forgot-password.component.html',
providers:[AlertService, AuthenticationService, ForgotpasswordService]
})
export class ForgetPasswordComponent implements OnInit {
model: any = {};
loading = false;
constructor(
private router: Router,
private authenticationService: AuthenticationService,
private forgotpasswordService: ForgotpasswordService,
private alertService: AlertService) { }
ngOnInit() {
// reset login status
this.authenticationService.logout();
}
forgotPassword() {
this.loading = true;
this.forgotpasswordService.forgotPassword(this.model.email)
.subscribe(
data => console.log("yesss"),
error => {
console.log("yesss");
}
);
}
}