In my Angular 6 application, I need a function that does nothing. Obviously, I could just write my own, but I was reading about angular.noop which I would like to use. However, I get an angular.noop is not a function
error when I try to use it. I could not find anything about this in Angular's documentation. Is there an Angular 6 version of AngularJS's angular.noop function?
I know what noop is. This is not a duplicate of What is Angular.noop used for?. I am asking about Angular 6. My question is very simply "Is there a noop function built into Angular 6 like there is in AngularJS?".
A function that performs no operations. This function can be useful when writing code in the functional style. function foo(callback) { var result = calculateResult(); (callback || angular. noop)(result); }
https://rxjs.dev/api/index/function/noop. A function that does nothing. This is one of those things that you boggle at until you actually need it for something.
You could use noop
which is a helper function from Rxjs
for this:
import { noop } from 'rxjs';
...
// this does nothing.
noop();
I don't really think Angular has noop
This does nothing:
()=>{}
It's no more characters than noop() and doesn't need an import.
I'm assuming you want to use this with (click)
. Try:
(click)="!!false"
it works and the compiler doesn't complain. Maybe there is a more semantic solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With