angular2-routing

How to create a link to external URL in Angular 2

时光怂恿深爱的人放手 提交于 2020-07-18 03:46:20
问题 I am new to Angular. I am starting with ver. 2. I need to link to a file://... URL. I tried normal href : Note: app is a model object of the web which deals with applications. <a target="_blank" href="file://{{app.outputPath}}/index.html">no link here</a>. That doesn't work - the link is there, with correct URL, but Angular seems to block the event somehow. Why? So I've seen ng-href but that's for Angular 1.x. And there's no *ngHref from what I can tell. So this was just a naive try: <a

How to create a link to external URL in Angular 2

痴心易碎 提交于 2020-07-18 03:45:29
问题 I am new to Angular. I am starting with ver. 2. I need to link to a file://... URL. I tried normal href : Note: app is a model object of the web which deals with applications. <a target="_blank" href="file://{{app.outputPath}}/index.html">no link here</a>. That doesn't work - the link is there, with correct URL, but Angular seems to block the event somehow. Why? So I've seen ng-href but that's for Angular 1.x. And there's no *ngHref from what I can tell. So this was just a naive try: <a

routerLink absolute url

核能气质少年 提交于 2020-07-02 07:56:34
问题 From angular docs : The router link directive always treats the provided input as a delta to the current url. For instance, if the current url is /user/(box//aux:team) . Then the following link <a [routerLink]="['/user/jim']">Jim</a> will generate the link /user/(jim//aux:team) . So how do you create a link to /user/jim ? I tried ['/user/jim', { outlets: { aux: null }}] but this isn't working. Even if it worked it wouldn't have been a optimal solution. I'm rather looking for a way to navigate

routerLink absolute url

我是研究僧i 提交于 2020-07-02 07:56:11
问题 From angular docs : The router link directive always treats the provided input as a delta to the current url. For instance, if the current url is /user/(box//aux:team) . Then the following link <a [routerLink]="['/user/jim']">Jim</a> will generate the link /user/(jim//aux:team) . So how do you create a link to /user/jim ? I tried ['/user/jim', { outlets: { aux: null }}] but this isn't working. Even if it worked it wouldn't have been a optimal solution. I'm rather looking for a way to navigate

Cannot pass data with service in angular2

十年热恋 提交于 2020-06-28 04:16:06
问题 PS: When I talk to my colleague, they told me to get Role's right with once request, if it is not authenticated then reject, else return the data to frond-end. But, I got stuck in use Angular2's Guard. Apps do: Access my routes, and Guard prevent it, the Guard send a request to server to check its auth. Request the server , when server return statue:true and data:[somedatas] then set data with module's dataService , and resolve true for canActivate. Init the target component, in constructor ,

Router link not working for a component inside a shared module

扶醉桌前 提交于 2020-06-24 20:48:46
问题 I have written a module named "Customer" which has several components like login, home and register. Now I have created a shared module which is also having 2 components such as header and footer. Since header and footer are going to be shared by all the components in the customer module I have placed them in the shared module. The shared module is imported to the customer module. Now there is a router link which points to the component inside customer module. Those router link are not

Angular2 how to Mock Activated Route Params subscribed

旧时模样 提交于 2020-06-12 16:16:48
问题 I have a components that gets a value from the params property of a ActivatedRoute. The components looks like: ...... constructor(public userRegistration: UserRegistrationService, public userLogin: UserLoginService, public router: Router, public route: ActivatedRoute) { } ngOnInit() { this.verificationCode = new FormControl('', [Validators.required]); this.confirmationCodeForm = new FormGroup({verificationCode: this.verificationCode}); //****************************** this.sub = this.route

Angular2 how to Mock Activated Route Params subscribed

烈酒焚心 提交于 2020-06-12 16:15:24
问题 I have a components that gets a value from the params property of a ActivatedRoute. The components looks like: ...... constructor(public userRegistration: UserRegistrationService, public userLogin: UserLoginService, public router: Router, public route: ActivatedRoute) { } ngOnInit() { this.verificationCode = new FormControl('', [Validators.required]); this.confirmationCodeForm = new FormGroup({verificationCode: this.verificationCode}); //****************************** this.sub = this.route

Angular2 how to Mock Activated Route Params subscribed

孤街醉人 提交于 2020-06-12 16:13:42
问题 I have a components that gets a value from the params property of a ActivatedRoute. The components looks like: ...... constructor(public userRegistration: UserRegistrationService, public userLogin: UserLoginService, public router: Router, public route: ActivatedRoute) { } ngOnInit() { this.verificationCode = new FormControl('', [Validators.required]); this.confirmationCodeForm = new FormGroup({verificationCode: this.verificationCode}); //****************************** this.sub = this.route

Get current route without parameters

假如想象 提交于 2020-06-10 07:21:10
问题 I need to get my current route without params in Angular 2, I found a way to get the current route with params as follows: this.router.url and then split it: this.router.url.split(';')[0] But this looks as workaround, I think there should be better way? 回答1: parseTree from Router helps fetching the segments without any knowledge about url structure. import { Router } from '@angular/router'; ... constructor(private router: Router) {} ... const urlTree = this.router.parseUrl(url); const