aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2010-05-13 12:03:34 -0700
committerMisko Hevery2010-05-13 12:03:34 -0700
commitd523ab61d4e5887bba9466a6ce1703befd1663e4 (patch)
treeb83aa079e0f68f8b33ea4c26a05fddc0e686dc52 /src
parent4b9b9e98300b9554faf0c960674eb75750227404 (diff)
parentd5ba889f63d3ce8abe49c24695f5f5c964b40264 (diff)
downloadangular.js-d523ab61d4e5887bba9466a6ce1703befd1663e4.tar.bz2
Merge branch 'master' of github.com:angular/angular.js
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js3
-rw-r--r--src/widgets.js18
2 files changed, 15 insertions, 6 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 2df6bbef..8675bc40 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -379,7 +379,8 @@ function toKeyValue(obj) {
function angularInit(config){
if (config.autobind) {
var scope = compile(window.document, null, {'$config':config});
- scope.$browser.addCss('../css/angular.css');
+ // TODO default to the source of angular.js
+ scope.$browser.addCss('css/angular.css');
scope.$init();
}
}
diff --git a/src/widgets.js b/src/widgets.js
index 24c85464..4eae735f 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -7,7 +7,7 @@ function modelAccessor(scope, element) {
},
set: function(value) {
if (value !== undefined) {
- scope.$tryEval(expr + '=' + toJson(value), element);
+ return scope.$tryEval(expr + '=' + toJson(value), element);
}
}
};
@@ -37,7 +37,9 @@ function valueAccessor(scope, element) {
if (lastError)
elementError(element, NG_VALIDATION_ERROR, null);
try {
- return parse(element.val());
+ var value = parse(element.val());
+ validate();
+ return value;
} catch (e) {
lastError = e;
elementError(element, NG_VALIDATION_ERROR, e);
@@ -163,13 +165,15 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) {
var scope = this,
model = modelAccessor(scope, element),
view = viewAccessor(scope, element),
- action = element.attr('ng-change') || '';
+ action = element.attr('ng-change') || '',
+ lastValue;
initFn.call(scope, model, view, element);
this.$eval(element.attr('ng-init')||'');
// Don't register a handler if we are a button (noopAccessor) and there is no action
if (action || modelAccessor !== noopAccessor) {
element.bind(events, function(){
model.set(view.get());
+ lastValue = model.get();
scope.$tryEval(action, element);
scope.$root.$eval();
// if we have noop initFn than we are just a button,
@@ -177,8 +181,12 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) {
return initFn != noop;
});
}
- view.set(model.get());
- scope.$watch(model.get, view.set);
+ view.set(lastValue = model.get());
+ scope.$watch(model.get, function(value){
+ if (lastValue !== value) {
+ view.set(lastValue = value);
+ }
+ });
};
}