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