akveo / akveo/nebular

Stopping Spinners in ngOnInit

未关闭
#1,645 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
needs info
主要语言
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

This is my 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 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。