I am new to angularJs2. My requirement is that I want multiple templates in single component. Like I have ForgetPasswordComponent and there are two routes with name forgot-password and password/reset. So I want to call diff-diff templates on diff routes. Currently the forgot-password.component.html is calling on forgot-password route and now I want to call diff. template on password/reset route. Here is my code.
app-routing.module.ts
{ path: 'forgot-password', component: ForgetPasswordComponent },
{ path: 'password/reset', component: ForgetPasswordComponent },
forget-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");
}
);
}
}