@@ -105,6 +105,53 @@ angularTextMarkup('option', function(text, textNode, parentElement){
105
105
*
106
106
* @element ANY
107
107
* @param {template } template any string which can contain `{{}}` markup.
108
+ *
109
+ * @example
110
+ * This example uses `link` variable inside `href` attribute:
111
+ <doc:example>
112
+ <doc:source>
113
+ <input name="value" /><br />
114
+ <a id="link-1" href ng:click="value = 1">link 1</a> (link, don't reload)<br />
115
+ <a id="link-2" href="" ng:click="value = 2">link 2</a> (link, don't reload)<br />
116
+ <a id="link-3" ng:href="#{{'123'}}" ng:click="value = 3">link 3</a> (link, reload!)<br />
117
+ <a id="link-4" href="" name="xx" ng:click="value = 4">anchor</a> (link, don't reload)<br />
118
+ <a id="link-5" name="xxx" ng:click="value = 5">anchor</a> (no link)<br />
119
+ <a id="link-6" ng:href="#/{{value}}">link</a> (link, change hash)
120
+ </doc:source>
121
+ <doc:scenario>
122
+ it('should execute ng:click but not reload when href without value', function() {
123
+ element('#link-1').click();
124
+ expect(element('input[name=value]').val()).toEqual('1');
125
+ });
126
+
127
+ it('should execute ng:click but not reload when href empty string', function() {
128
+ element('#link-2').click();
129
+ expect(element('input[name=value]').val()).toEqual('2');
130
+ });
131
+
132
+ it('should execute ng:click and change url when ng:href specified', function() {
133
+ element('#link-3').click();
134
+ expect(element('input[name=value]').val()).toEqual('3');
135
+ expect(browser().location().hash()).toEqual('123');
136
+ });
137
+
138
+ it('should execute ng:click but not reload when href empty string and name specified', function() {
139
+ element('#link-4').click();
140
+ expect(element('input[name=value]').val()).toEqual('4');
141
+ });
142
+
143
+ it('should execute ng:click but not reload when no href but name specified', function() {
144
+ element('#link-5').click();
145
+ expect(element('input[name=value]').val()).toEqual('5');
146
+ });
147
+
148
+ it('should only change url when only ng:href', function() {
149
+ input('value').enter('6');
150
+ element('#link-6').click();
151
+ expect(browser().location().hash()).toEqual('/6');
152
+ });
153
+ </doc:scenario>
154
+ </doc:example>
108
155
*/
109
156
110
157
/**
0 commit comments