{"id":13661159,"url":"https://github.com/jinhduong/ng2-loading-indicator","last_synced_at":"2025-04-12T06:32:07.738Z","repository":{"id":143896670,"uuid":"97145953","full_name":"jinhduong/ng2-loading-indicator","owner":"jinhduong","description":"Angular 2/4 loading indicator","archived":false,"fork":false,"pushed_at":"2019-04-12T09:24:13.000Z","size":41,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T02:03:38.088Z","etag":null,"topics":["angular","angular2","loading-indicator","loading-spinner"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jinhduong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-13T16:52:01.000Z","updated_at":"2019-08-31T04:33:10.000Z","dependencies_parsed_at":"2024-01-15T20:51:30.740Z","dependency_job_id":"1f74863b-24c8-4f7a-b562-198d536b6dde","html_url":"https://github.com/jinhduong/ng2-loading-indicator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinhduong%2Fng2-loading-indicator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinhduong%2Fng2-loading-indicator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinhduong%2Fng2-loading-indicator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinhduong%2Fng2-loading-indicator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jinhduong","download_url":"https://codeload.github.com/jinhduong/ng2-loading-indicator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262434,"owners_count":21074308,"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","angular2","loading-indicator","loading-spinner"],"created_at":"2024-08-02T05:01:30.464Z","updated_at":"2025-04-12T06:32:07.376Z","avatar_url":"https://github.com/jinhduong.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ng2-loading-indicator @decorator\n![npm-image](https://img.shields.io/npm/v/ng2-loading-indicator.svg)\n![downloads-image](https://img.shields.io/npm/dm/ng2-loading-indicator.svg)\n![total-downloads-image](https://img.shields.io/npm/dt/ng2-loading-indicator.svg)\n\nThe simplest library for loading indicator @decorator in Angular 2/4.\n\n- No dependencies\n- Simplest\n\n![https://media.giphy.com/media/3o7buiqQhDuGYmc2go/giphy.gif](https://media.giphy.com/media/3o7buiqQhDuGYmc2go/giphy.gif)\n\n## 1. Install\n`npm install ng2-loading-indicator --save`\n\n## 2. Using\n\n### Add into `.component`\n```js\nimport { LoadingIndicator } from 'ng2-loading-indicator';\n```\n\n### **We have 2 ways to use this decorator in our code:**\n\n### 1. Whole page loading\n\n#### 1.1 When return a `Subscription` after call `.subscribe`\n\n```js\n  @LoadingIndicator()\n  tryLoadingIndicator() {\n    return Observable.timer(3000).subscribe(x =\u003e {\n      console.log('finished 3s');\n    });\n  }\n```\n\n- Other cases in `http`,`forms`,... anything in Angular are using `rxjs`\n\n```js\n  @LoadingIndicator()\n  getDataFromApi() {\n    return this.http.get('your-api.com')\n    .map(res =\u003e res.json())\n    .subscribe(res =\u003e {});\n  }\n```\n\n#### 1.2 In async/await function\n\n```js\n@LoadingIndicator()\nasync tryLoadingIndicator() {\n  await Observable.timer(3000).toPromise();\n}\n```\n\n#### 1.3 When return a `Observable\u003cT\u003e` after call from operators `do`, `map`,...\n\n```js\n  @LoadingIndicator()\n  tryLoadingIndicator() {\n    return Observable.timer(3000).do(x =\u003e {\n      console.log('finished 3s');\n    });\n  }\n```\n\n### 2. Parts of the page loading\n\n```js\n// Define a variable with HTMLElement\n$div: Element; \n\n// Using ElementRef to get DOM element for this component\nconstructor(private elementRef: ElementRef) {}\n\n// Set value for above variable (HTMLElement)\nngOnInit() {\n    this.$div = this.elementRef.nativeElement.querySelector('div');\n}\n\n// Add the variable string list to @decorator\n@LoadingIndicator(['$div'])\nasync trySectionLoading() {\n  await Observable.timer(3000).toPromise();\n}\n```\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinhduong%2Fng2-loading-indicator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjinhduong%2Fng2-loading-indicator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinhduong%2Fng2-loading-indicator/lists"}