2 Copyright 2020 TATA ELXSI
4 Licensed under the Apache License, Version 2.0 (the 'License');
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
19 * @file Roles component.
21 import { Component, Injector } from '@angular/core';
22 import { Router, RouterEvent } from '@angular/router';
26 * @Component takes RolesComponent.html as template url
29 selector: 'app-roles',
30 templateUrl: './RolesComponent.html',
31 styleUrls: ['./RolesComponent.scss']
34 /** Exporting a class @exports RolesComponent */
35 export class RolesComponent {
36 /** Invoke service injectors @public */
37 public injector: Injector;
39 /** Holds teh instance of router service @private */
40 private router: Router;
42 // creates role datails component
43 constructor(injector: Injector) {
44 this.injector = injector;
45 this.router = this.injector.get(Router);
46 this.router.events.subscribe((event: RouterEvent) => {
47 this.redirectToList(event.url);
51 /** Return to role datails list */
52 public redirectToList(getURL: string): void {
53 if (getURL === '/roles') {
54 this.router.navigate(['/roles/details']).catch((): void => {
55 // Catch Navigation Error