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+
- Host: GitHub
- URL: https://github.com/amitport/ngx-init
- Owner: amitport
- License: mit
- Created: 2018-06-02T09:32:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T23:30:31.000Z (about 3 years ago)
- Last Synced: 2025-10-11T06:54:52.323Z (6 months ago)
- Topics: angular
- Language: TypeScript
- Homepage:
- Size: 1.72 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```
```html
```
### 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
```
```html
```
### with async pipe
```html
{{state.G.cells[id]}}
```