什么是用于Angular.noop? [英] What is Angular.noop used for?

查看:139
本文介绍了什么是用于Angular.noop?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

十一试图甚至Angular.org文档搜索无处不在,但未能找到任何实施详细的解释。这将是非常有益的,如果任何可以解释的。

XI 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.

推荐答案

angular.noop是可以作为当你需要通过一些函数作为参数占位符一个空函数。

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

这篇关于什么是用于Angular.noop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆