Difference between “href” and “ng-href” in AngularJS

前端 未结 2 579
再見小時候
再見小時候 2021-02-05 04:21

I\'ve used both href and ng-href and I couldn\'t see the difference between them.

Why does Angular have the ng-href attribute, and

2条回答
  •  星月不相逢
    2021-02-05 05:22

    If you need to bind values from your model you use the directive. For example:

    Dynamic link
    Change the link dynamically:

    In the example above, the value of address is programmatically bound to the value in the input text box, which you can change.

    If you don't need to be dynamic (i.e. react to a change in the model's state), then you can simply stay with href:

    Static link
    

提交回复
热议问题