Skip to content

Commit 2ba2225

Browse files
committed
Added ng:options directive
Closes angular#301
1 parent b0e0c05 commit 2ba2225

13 files changed

+517
-166
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<a name="0.9.16"><a/>
22
# <angular/> 0.9.16 weather-control (in-progress) #
33

4+
### New Features
5+
- Added ng:options directive (http://docs.angularjs.org/#!angular.directive.ng:options)
6+
47
### Breaking changes
8+
- Dynamic Iteration (ng:repeater) on <option> elements is no longer supported. Use ng:options
59
- $service now has $service.invoke for method injection ($service(self, fn) no longer works)
610
- injection name inference no longer supports method curry and linking functions. Both must be
711
explicitly specified using $inject property.
812

9-
10-
1113
<a name="0.9.15"><a/>
1214
# <angular/> 0.9.15 lethal-stutter (2011-04-11) #
1315

src/Angular.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function fromCharCode(code) { return String.fromCharCode(code); }
5454

5555
var _undefined = undefined,
5656
_null = null,
57-
$$update = '$update',
5857
$$scope = '$scope',
5958
$$validate = '$validate',
6059
$angular = 'angular',

src/Scope.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,7 @@ Scope.prototype = {
716716
* @returns {*} The result of evaluating the expression.
717717
*/
718718
$eval: function(expr) {
719-
var fn = isString(expr)
720-
? parser(expr).statements()
721-
: expr || noop;
722-
return fn(this);
719+
return (isString(expr) ? compileExpr(expr) : expr || noop)(this);
723720
},
724721

725722
/**

src/directives.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,8 @@ var REMOVE_ATTRIBUTES = {
425425
angularDirective("ng:bind-attr", function(expression){
426426
return function(element){
427427
var lastValue = {};
428-
var updateFn = element.data($$update) || noop;
429428
this.$observe(function(scope){
430-
var values = scope.$eval(expression),
431-
dirty = noop;
429+
var values = scope.$eval(expression);
432430
for(var key in values) {
433431
var value = compileBindTemplate(values[key])(scope, element),
434432
specialName = REMOVE_ATTRIBUTES[lowercase(key)];
@@ -446,10 +444,8 @@ angularDirective("ng:bind-attr", function(expression){
446444
} else {
447445
element.attr(key, value);
448446
}
449-
dirty = updateFn;
450447
}
451448
}
452-
dirty();
453449
});
454450
};
455451
});

src/formatters.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ angularFormatter.trim = formatter(
181181
* @workInProgress
182182
* @ngdoc formatter
183183
* @name angular.formatter.index
184+
* @deprecated
184185
* @description
185186
* Index formatter is meant to be used with `select` input widget. It is useful when one needs
186187
* to select from a set of objects. To create pull-down one can iterate over the array of object
@@ -227,6 +228,7 @@ angularFormatter.trim = formatter(
227228
</doc:scenario>
228229
</doc:example>
229230
*/
231+
//TODO: delete me since this is replaced by ng:options
230232
angularFormatter.index = formatter(
231233
function(object, array){
232234
return '' + indexOf(array || [], object);

src/jqLite.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,20 @@ forEach({
356356
});
357357
},
358358

359+
prepend: function(element, node) {
360+
if (element.nodeType === 1) {
361+
var index = element.firstChild;
362+
forEach(new JQLite(node), function(child){
363+
if (index) {
364+
element.insertBefore(child, index);
365+
} else {
366+
element.appendChild(child);
367+
index = child;
368+
}
369+
});
370+
}
371+
},
372+
359373
remove: function(element) {
360374
JQLiteDealoc(element);
361375
var parent = element.parentNode;

src/parser.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ function parser(text, json){
239239
pipeFunction =
240240
function (){ throwError("is not valid json", {text:text, index:0}); };
241241
}
242+
//TODO: Should'nt all of the public methods have assertAllConsumed?
243+
//TODO: I think these should be public instead of scope.$eval() being the enterenece.
242244
return {
243245
assignable: assertConsumed(assignable),
244246
primary: assertConsumed(primary),
@@ -748,12 +750,17 @@ function getterFn(path){
748750

749751
///////////////////////////////////
750752

751-
//TODO: Deprecate? Remove?
753+
//TODO: Should this function be public?
754+
function compileExpr(expr) {
755+
return parser(expr).statements();
756+
}
757+
758+
//TODO: Deprecate? Remove!
752759
function expressionCompile(exp){
753760
if (typeof exp === $function) return exp;
754761
var fn = compileCache[exp];
755762
if (!fn) {
756-
fn = compileCache[exp] = parser(exp).statements();
763+
fn = compileCache[exp] = compileExpr(exp);
757764
}
758765
return fn;
759766
}

0 commit comments

Comments
 (0)