【发布时间】:2017-04-15 22:27:18
【问题描述】:
我是 angularJs2 的新手。我的要求是我想要单个组件中的多个模板。就像我有ForgetPasswordComponent 一样,有两条路线的名称为forgot-password 和password/reset。所以我想在 diff 路由上调用 diff-diff 模板。目前forgot-password.component.html 正在调用forgot-password 路由,现在我想调用diff。 password/reset 路线上的模板。 这是我的代码。
app-routing.module.ts
{ path: 'forgot-password', component: ForgetPasswordComponent },
{ path: 'password/reset', component: ForgetPasswordComponent },
忘记密码.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");
}
);
}
}
【问题讨论】:
标签: templates angular routing components