{"id":20349036,"url":"https://github.com/anirudhvarma12/ngx-var","last_synced_at":"2025-04-12T01:22:40.310Z","repository":{"id":53727131,"uuid":"332462872","full_name":"anirudhvarma12/ngx-var","owner":"anirudhvarma12","description":"Angular directive to easily consume and re-assign any observable in templates","archived":false,"fork":false,"pushed_at":"2024-06-10T10:17:23.000Z","size":952,"stargazers_count":2,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T14:50:06.899Z","etag":null,"topics":["angular","rxjs","typescript"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/ngx-var-demo?file=src/app/app.component.html","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anirudhvarma12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-24T13:56:15.000Z","updated_at":"2024-06-10T10:09:07.000Z","dependencies_parsed_at":"2024-06-10T11:55:45.372Z","dependency_job_id":null,"html_url":"https://github.com/anirudhvarma12/ngx-var","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.0714285714285714,"last_synced_commit":"6fa3cfa8010e046e2023b05888d9677c7f05f588"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhvarma12%2Fngx-var","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhvarma12%2Fngx-var/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhvarma12%2Fngx-var/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anirudhvarma12%2Fngx-var/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anirudhvarma12","download_url":"https://codeload.github.com/anirudhvarma12/ngx-var/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248502101,"owners_count":21114738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","rxjs","typescript"],"created_at":"2024-11-14T22:23:53.834Z","updated_at":"2025-04-12T01:22:40.285Z","avatar_url":"https://github.com/anirudhvarma12.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `*ngxVar`\n\nAngular developers often use `*ngIf=\"foo$ | async as foo` to consume an observable easily in templates. However, this approach does not work if your observable emits a boolean as the `ngIf` will hide the template when the source observable emits a falsy value.\n\n`*ngxVar` allows developers to easily consume any observable (or static values) regardless of the type.\n\n# Installation\n```\nnpm i --save ngx-var\n```\n\n## Import the module\n\n```ts\nimport { NgxVarModule } from \"ngx-var\"\n\n@NgModule({\n  imports: [NgxVarModule],\n})\nclass AppModule {}\n```\n\n# Examples\n(Examples taken from tests)\n\n## TestComponent\n\n```ts\nclass TestComponent {\n  numberObservable$: Observable\u003cnumber\u003e;\n  boolObservable$: Observable\u003cboolean\u003e;\n  sampleString = 'aa';\n  sampleFunc = (a: number, b: number) =\u003e a * b;\n}\n```\n\n## Use with a single boolean observable \n\n```html\n\u003cng-container *ngxVar=\"boolObservable$ | async as bool\"\u003e\n    \u003cspan\u003e{{bool ? 'true':'false'}}\u003c/span\u003e\n\u003c/ng-container\u003e`\n```\n\n## Use with multiple values\n\n```html\n\u003cng-container *ngxVar=\"{ a: numberObservable$ | async, b: sampleString } as data\"\u003e\n    {{data.a}} {{data.b}}\n\u003c/ng-container\u003e\n```\n* Note: As you can see, `sampleString` is not an observable value, but can still be used.\n\n## Use with `let` syntax\n\n```html\n\u003cspan *ngxVar=\"sampleFunc(5, 5); let data\"\u003e\n    {{data}}\n\u003c/span\u003e\n```\n\n# Development\n\n## Running unit tests\n\nRun `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).\n\n## Build\n\nRun `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.\n\n# LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2021 Anirudh Varma\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanirudhvarma12%2Fngx-var","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanirudhvarma12%2Fngx-var","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanirudhvarma12%2Fngx-var/lists"}