Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

javascript - What is Angular.noop used for?

I have tried searching it everywhere even on Angular.org documentation but couldn't find any detailed explanation with implementation. It would be hugely helpful if any could explain it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...