Tuesday, 13 June 2017

NG2- Router in Angular 2 component

import { Router } from '@angular/router';

export class App
Component{


construcot(private router: Router) {
    this.windowSize = window.innerWidth;
    this.url = router.url.split('/');
    this.arraylength = this.url.length;
    this.category = this.url[this.arraylength - 2];
    this.uniqueId = unescape(this.url[this.arraylength - 1]);


}

}

No comments:

Post a Comment

KISS, DRY, SOLID, YAGNI — A Simple Guide to Some Principles of Software Engineering and Clean Code

1 — KISS (Keep It Simple, Stupid)  Simplicity triumphs over complexity. Direct and clear codes are better for developing, maintaining, and s...