How to create a link to external URL in Angular 2

后端 未结 1 1423
礼貌的吻别
礼貌的吻别 2021-02-19 09:39

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 m

1条回答
  •  离开以前
    2021-02-19 09:55

    I assume app is assigned async. You can work around this using the Elvis operator:

    no link here.
    

    to not break the binding when Angular tries to resolve it before app actually has a value.

    Original This worked for example:

    @Component({
      selector: 'my-app',
      template: `
      

    Hello {{name}}

    no link here ` }) export class App { outputPath:string = 'www.google.com'; constructor() { this.name = 'Angular2'; } }

    Plunker

    Actually, your first example works fine as well

    no link here
    

    Plunker

    0 讨论(0)
提交回复
热议问题