Stopping Spinners in ngOnInit
- 主要语言
- TypeScript
- 星标
- 8.1k
- 派生
- 1.5k
- PR 合并指标
- 30 天内没有已合并 PR
描述
**I'm submitting a ...** (check one with "x")
- [ ] bug report
- [x] feature request
### Issue description
**Current behavior:**
if you put the change of the variable linked to the spinner showing in the ngOnInit, it does not stop the spinner. It does not matter if you wait for http.get or if you just use setTimeout like in the examples.
if you use a button click event to change the variable, it works
**Expected behavior:**
Spinners should be stopped in ngOnInit, too, as this is the place where you load data from APIs
**Related code:**
```
https://github.com/AtzederSerbe/Nebular-Test
import { Component } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
})
export class HomeComponent {
loading = true;
NgOnInit() {
setTimeout(() => this.loading=false,3000) // doesnt work
}
//works
setOff() {
this.loading = false;
}
setOn() {
this.loading = true;
}
```
html:
```
Home Component Card Test
On
Off
```
### Other information:
**npm, node, OS, Browser**
```
npm v 6.9.0
```
**Angular, Nebular**
```
"dependencies": {
"@angular/animations": "8.0.0",
"@angular/common": "8.0.0",
"@angular/compiler": "8.0.0",
"@angular/core": "8.0.0",
"@angular/forms": "8.0.0",
"@angular/platform-browser": "8.0.0",
"@angular/platform-browser-dynamic": "8.0.0",
"@angular/platform-server": "8.0.0",
"@angular/router": "8.0.0",
"@nguniversal/module-map-ngfactory-loader": "8.0.0-rc.1",
"core-js": "^2.6.5",
"rxjs": "^6.5.2",
"zone.js": "0.9.1",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.3.1",
"jquery": "3.3.1",
"oidc-client": "^1.6.1",
"popper.js": "^1.14.3",
"@nebular/theme": "4.1.0",
"@angular/cdk": "8.0.0",
"@nebular/eva-icons": "4.1.0",
"ng-http-cache": "1.2.0",
"eva-icons": "1.1.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.801.0-beta.2",
"@angular/cli": "8.0.0",
"@angular/compiler-cli": "8.0.0",
"@angular/language-service": "8.0.0",
"@types/jasmine": "~3.3.12",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~11.10.5",
"codelyzer": "~4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"typescript": "3.4.5"
},
"optionalDependencies": {
"node-sass": "4.12.0",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
```
贡献指南
评估
这个 Issue 还没有评估数据。