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

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

问题描述

即使在 Angular.org 文档中,我也尝试在任何地方搜索它,但找不到任何详细的实现说明.如果有人能解释一下,那将是非常有帮助的.

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.

推荐答案

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天全站免登陆