An open API service indexing awesome lists of open source software.

https://github.com/amitport/ngx-init

Angular.js' ng-init directive for Angular2+
https://github.com/amitport/ngx-init

angular

Last synced: 2 months ago
JSON representation

Angular.js' ng-init directive for Angular2+

Awesome Lists containing this project

README

          

# NgxInit

Angular.js' [ng-init directive](https://docs.angularjs.org/api/ng/directive/ngInit) for Angular.

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.3.18.

## usage

The usage involves some boilerplate, but that's the best Angular currently has to offer

0) import `NgxInitModule`
0) a value expression is set via `[ngxInit]` on an `ng-template` and published into a variable name via `let-=ngxInit`

## Examples

### simple

the following are equivalent (assuming `i` and `j` are defined in the context):

```html

{{idx}}

```

```html

{{idx}}

this is the {{idx}} index

```

```html

{{idx}}

this is the {{idx}} index

```

### inside ngFor

In the simple case, this directive cannot be used inside `ngFor` because in angular we can't have multiple template bindings on one element.
In order to bypass this limitation we can use either `ng-container` or `ng-template`

```html


{{sqr}}

```

Workarounds:

```html

{{sqr}}

```

```html

{{sqr}}

```

### with async pipe

```html




{{state.G.cells[id]}}


```