AngularJS ng-href directive
AngularJS instance
Add links using AngularJS settings:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body ng-app=""><div ng-init="myVar = 'http://www.runoob.com'"><h1>Rookie Tutorial</h1><p>Access <a ng-href="{{myVar}}">{{myVar}}</a> Learn!</p></div><p>This instance can use the native href attribute, but in AngularJS, The ng-href attribute is safer. </p></body></html>Definition and usage
The ng-href directive overrides the native <a> element href attribute.
If you have AngularJS code in the value of href, you need to use ng-href instead of href.
The ng-href directive ensures that the link is normal, even if you click the link before AngularJS executes the code.
grammar
<a ng-href="string"></a>
The <a> element supports this directive.
Parameter value
| value | describe |
|---|---|
| Expression | string, expression execution result |
The above is a compilation of AngularJS no-href data. We will continue to add it later. I hope it can help students who study AngularJS.