文字
分享

AngularJS: API: ng/function/angular.noop

angular.noop

  1. - function in module ng

一个执行空操作的函数。这个函数在使用函数风格写代码时很有用。

1

2

3

4

<code style="box-sizing:border-box;font-family:Menlo, Monaco, Consolas, 'Courier New', monospace;font-size:inherit;padding:0px;color:inherit;background-color:transparent;white-space:pre-wrap;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;"><span style="box-sizing:border-box;color:rgb(51, 51, 51);">     </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">Function</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);"> foo</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">(</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">callback</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">)</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);"> </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">{</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">

       </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">var</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);"> result </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">=</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);"> calculateResult</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">();</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">

       </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">(</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">callback </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">||</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);"> angular</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">.</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">noop</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">)(</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">result</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">);</span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">

     </span><span style="box-sizing:border-box;color:rgb(51, 51, 51);">}</span></code>

用法

angular.noop();