OLD | NEW |
(Empty) | |
| 1 part of angular.directive; |
| 2 |
| 3 /** |
| 4 * @ngdoc directive |
| 5 * @name ng.directive:a |
| 6 * @restrict E |
| 7 * |
| 8 * @description |
| 9 * Modifies the default behavior of the html A tag so that the default action is |
| 10 * prevented when the a href is empty or it contains `ng-click` directive. |
| 11 * |
| 12 * This change permits the easy creation of action links with the `ngClick` |
| 13 * directive without changing the location or causing page reloads, e.g.: |
| 14 * `<a href="" ng-click="model.save()">Save</a>` |
| 15 */ |
| 16 @Decorator(selector: 'a[href]') |
| 17 class AHref { |
| 18 final dom.Element element; |
| 19 |
| 20 AHref(this.element, VmTurnZone zone) { |
| 21 if (element.attributes["href"] == "") { |
| 22 zone.runOutsideAngular(() { |
| 23 element.onClick.listen((event) { |
| 24 if (element.attributes["href"] == "") { |
| 25 event.preventDefault(); |
| 26 } |
| 27 }); |
| 28 }); |
| 29 } |
| 30 } |
| 31 } |
OLD | NEW |