UrlSegment Interface - UrlSegment interface represents a single URL segment and the constructor, properties, and methods look like below UrlSegment class i.e. class UrlSegment { constructor ( path : string , parameters : {...}) path : string parameters : {...} toString (): string } The UrlSegment is a part of a URL between the two slashes and it contains a path and matrix parameters associated with the segment. Stayed In formed - Angular 7 Interview Questions Example: @ Component ({ templateUrl: './user.component.html' , styleUrls: [ './user.component.css' ] }) class UserComponent { constructor ( router : Router ) { const urlTree : UrlTree = router . parseUrl ( '/user;id=101' ); const urlSGroup : UrlSegmentGroup = urlTree . root . children [ PRIMARY_OUTLET ]; const urlSegment : UrlSegment [] = urlSGroup . segments ; urlSegment [ 0 ]. path ; // It will returns 'user' urlSegment [ 0 ]. parameters ; ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers