@@ -153,98 +153,3 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
153
153
} ) ;
154
154
}
155
155
} ] ;
156
-
157
-
158
- /**
159
- * @ngdoc directive
160
- * @name angular.module.ng.$compileProvider.directive.ng-bind-attr
161
- * @restrict A
162
- *
163
- * @description
164
- * The `ng-bind-attr` attribute specifies that a
165
- * {@link guide/dev_guide.templates.databinding databinding} should be created between a particular
166
- * element attribute and a given expression. Unlike `ng-bind`, the `ng-bind-attr` contains one or
167
- * more JSON key value pairs; each pair specifies an attribute and the
168
- * {@link guide/dev_guide.expressions expression} to which it will be mapped.
169
- *
170
- * Instead of writing `ng-bind-attr` statements in your HTML, you can use double-curly markup to
171
- * specify an <tt ng-non-bindable>{{expression}}</tt> for the value of an attribute.
172
- * At compile time, the attribute is translated into an
173
- * `<span ng-bind-attr="{attr:expression}"></span>`.
174
- *
175
- * The following HTML snippet shows how to specify `ng-bind-attr`:
176
- * <pre>
177
- * <a ng-bind-attr='{"href":"http://www.google.com/search?q={{query}}" }'>Google</a>
178
- * </pre>
179
- *
180
- * This is cumbersome, so as we mentioned using double-curly markup is a prefered way of creating
181
- * this binding:
182
- * <pre>
183
- * <a href="http://www.google.com/search?q={{query}}">Google</a>
184
- * </pre>
185
- *
186
- * During compilation, the template with attribute markup gets translated to the ng-bind-attr form
187
- * mentioned above.
188
- *
189
- * _Note_: You might want to consider using {@link angular.module.ng.$compileProvider.directive.ng-href ng-href} instead of
190
- * `href` if the binding is present in the main application template (`index.html`) and you want to
191
- * make sure that a user is not capable of clicking on raw/uncompiled link.
192
- *
193
- *
194
- * @element ANY
195
- * @param {string } ng-bind-attr one or more JSON key-value pairs representing
196
- * the attributes to replace with expressions. Each key matches an attribute
197
- * which needs to be replaced. Each value is a text template of
198
- * the attribute with the embedded
199
- * <tt ng-non-bindable>{{expression}}</tt>s. Any number of
200
- * key-value pairs can be specified.
201
- *
202
- * @example
203
- * Enter a search string in the Live Preview text box and then click "Google". The search executes instantly.
204
- <doc:example>
205
- <doc:source>
206
- <script>
207
- function Ctrl($scope) {
208
- $scope.query = 'AngularJS';
209
- }
210
- </script>
211
- <div ng-controller="Ctrl">
212
- Google for:
213
- <input type="text" ng-model="query" ng-model-instant>
214
- <a ng-bind-attr='{"href":"http://www.google.com/search?q={{query}}" }'>
215
- Google
216
- </a> (ng-bind-attr) |
217
- <a href="http://www.google.com/search?q={{query}}">Google</a>
218
- (curly binding in attribute val)
219
- </div>
220
- </doc:source>
221
- <doc:scenario>
222
- it('should check ng-bind-attr', function() {
223
- expect(using('.doc-example-live').element('a').attr('href')).
224
- toBe('http://www.google.com/search?q=AngularJS');
225
- using('.doc-example-live').input('query').enter('google');
226
- expect(using('.doc-example-live').element('a').attr('href')).
227
- toBe('http://www.google.com/search?q=google');
228
- });
229
- </doc:scenario>
230
- </doc:example>
231
- */
232
-
233
- var ngBindAttrDirective = [ '$interpolate' , function ( $interpolate ) {
234
- return function ( scope , element , attr ) {
235
- var lastValue = { } ;
236
- var interpolateFns = { } ;
237
- scope . $watch ( function ( ) {
238
- var values = scope . $eval ( attr . ngBindAttr ) ;
239
- for ( var key in values ) {
240
- var exp = values [ key ] ,
241
- fn = ( interpolateFns [ exp ] ||
242
- ( interpolateFns [ values [ key ] ] = $interpolate ( exp ) ) ) ,
243
- value = fn ( scope ) ;
244
- if ( lastValue [ key ] !== value ) {
245
- attr . $set ( key , lastValue [ key ] = value ) ;
246
- }
247
- }
248
- } ) ;
249
- }
250
- } ] ;
0 commit comments