2

How do I render a URL which is not encoded. Below is a sample

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

@Component({
  selector: 'demo-app',
  template: `<a [routerLink]="stringURL">Click here</a>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  stringURL:string;

  constructor(){
    this.stringURL = "/url;mode=3"
  }
}

The URL in the template has encoded string like /url%3Bmode%3D3 and I want it like /url;mode=3

How can I achieve this.

Here's the sample : https://stackblitz.com/edit/angular-q6mf3p

Thanks

2 Answers 2

4
+25

You have to disable angular default URL encoding.

This post explains the solution quite well.

Sign up to request clarification or add additional context in comments.

Comments

2

If the link is static, you can use the directive as follows: link to user component

If you use dynamic values to generate the link, you can pass an array of path segments, followed by the params for each segment.

For instance ['/url',{mode: 3}] means that we want to generate a link to /url;mode=3.

you code will work see this new link click to see

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

@Component({
  selector: 'demo-app',
  template: `<a [routerLink]="stringURL">Click here</a>`,
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  stringURL:any;

  constructor(){
    this.stringURL = ["/url",{mode:3}]
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.