Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@klippa/ngx-async-template

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@klippa/ngx-async-template - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

3

package.json
{
"name": "@klippa/ngx-async-template",
"version": "3.0.0",
"repository": "github:klippa-app/ngx-async-template",
"version": "3.0.1",
"publishConfig": {

@@ -5,0 +6,0 @@ "access": "public"

# NgxAsyncTemplate
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.1.6.
Easily render templates based on the state of a promise:
- inactive
- pending
- success
- error
## Code scaffolding
# Install guide
Run `ng generate component component-name --project ngx-async-template` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-async-template`.
> Note: Don't forget to add `--project ngx-async-template` or else it will be added to the default project in your `angular.json` file.
### yarn
`yarn add @klippa/ngx-async-template`
## Build
### npm
`npm install @klippa/ngx-async-template`
Run `ng build ngx-async-template` to build the project. The build artifacts will be stored in the `dist/` directory.
## Import
## Publishing
I recommend importing the module in a generic ui module and then export it from there, so you can use the ngx-async-template everywhere in your app.
After building your library with `ng build ngx-async-template`, go to the dist folder `cd dist/ngx-async-template` and run `npm publish`.
```js
import { NgxAsyncTemplateModule } from '@klippa/ngx-async-template';
## Running unit tests
@NgModule({
imports: [
NgxAsyncTemplateModule,
],
exports: [
NgxAsyncTemplateModule,
],
})
export class UiModule {}
```
Run `ng test ngx-async-template` to execute the unit tests via [Karma](https://karma-runner.github.io).
# Example
## Further help
```html
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
<ngx-async-template [promise]="userPromise">
<ng-template ngx-async-inactive>
loading not yet started
</ng-template>
<ng-template ngx-async-pending>
loading
</ng-template>
<ng-template ngx-async-success let-users="value">
result is {{users}}
</ng-template>
<ng-template ngx-async-error let-myErrors="errorMessages">
something went wrong {{myErrors}}
</ng-template>
<ng-template ngx-async-all let-myState="status">
Always rendered, state is {{myState}}
</ng-template>
</ngx-async-template>
```
# Usage
To render templates, use one or more of the following directives on a `ng-template`:
- ngx-async-inactive
- ngx-async-pending
- ngx-async-success
- ngx-async-error
- ngx-async-all
- You can extract the value of a successful promise by using `let-someVarName="value"` where `someVarName` can be any name you want.
- To extract errors provided by a promise you can use `let-myErrors="errorMessages"` where `myErrors` can be any name you want.
- You can also extract the status of a promise, which can be helpful if you have a template with multiple directives (`<ng-template ngx-async-inactive ngx-async-pending...`) with `let-myState="status"` where `myState` can be any name you want.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc