Interviews2 answers
What is the use of angular.noop in Angular 1.*?
2 Answers
angular.noop is an empty function that can be used as a placeholder when you need to pass some function as a param.
function foo (callback) {
// Do a lot of complex things
callback();
}
// Those two have the same effect, but the later is more elegant
foo(function() {});
foo(angular.noop);
Gajendra JangidPosted Jan 30, 2018, 10:04 PM EST
A function that performs no operations.
function method(callback) {
var result = calculateResult();
(callback || angular.noop)(result);
}
method(angular.noop); // no callback
method(alert(result)); // alert is a callback and alerts result
Useful in situations where we do not require a callback after doing some operation.
Santosh Kumar AdidawarpuPosted Nov 16, 2017, 2:55 PM EST

