Joined November 2012
·
Posted to
'Safe' $apply in Angular.JS
over 1 year
ago
Angular's apply is able to run without a function as a parameter, so it will propagate all previous changes to the UI.
I purpose this update:
$scope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
if(fn)
fn();
} else {
this.$apply(fn);
}
};
Achievements
18 Karma
0 Total ProTip Views
Forked
Have a project valued enough to be forked by someone else
Charity
Fork and commit to someone's open source project in need
I really didn't like the fact that restangular depends on lodash, and that it's not pre-configurable.
So I tried to create my own module which extends Angular's resource object to support nested models:
https://github.com/roypeled/angular-nested-resource