
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@avine/ng-if-non-nullish
Advanced tools
Nullish coalescing operator as Angular structural directive and more...
Nullish coalescing operator as Angular structural directive and more...
Check out demo here.
Import IfNonNullishDirective
(standalone directive) in your app.module.ts
:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IfNonNullishDirective } from '@avine/ng-if-non-nullish';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, IfNonNullishDirective],
bootstrap: [AppComponent],
})
export class AppModule {}
Use ifNonNullish
directive in your app.component.ts
:
import { Component } from '@angular/core';
import { interval, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@Component({
selector: 'app-root',
template: `<div *ifNonNullish="data$ | async as value">{{ value }}</div>`,
})
export class AppComponent {
data$: Observable<false | null> = interval(1000).pipe(map((i) => (i % 2 ? false : null)));
}
Unlike ngIf
directive, falsy values like false
, ""
or 0
are rendered.
Only nullish values like null
or undefined
are not rendered.
So, in the example above, false
will be rendered while null
will not.
Render data using "as" syntax or "implicit" syntax.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<div *ifNonNullish="data">{{ data }}</div>
<div *ifNonNullish="data as value">{{ value }}</div>
<div *ifNonNullish="data; let value">{{ value }}</div>
`,
})
export class AppComponent {
data: number | null = 0;
}
Use fallback:
input to provide a templateRef
when data is nullish.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<div *ifNonNullish="data as value; fallback: fallbackTemplate">
{{ value }}
</div>
<ng-template #fallbackTemplate>
<i>Fallback</i>
</ng-template>
`,
})
export class AppComponent {
data = undefined;
}
FAQs
Nullish coalescing operator as Angular structural directive and more...
The npm package @avine/ng-if-non-nullish receives a total of 20 weekly downloads. As such, @avine/ng-if-non-nullish popularity was classified as not popular.
We found that @avine/ng-if-non-nullish demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.