我想在Angular应用程序中使用微调器。我找到了一个叫做ngx-spinner的东西。但是,在实际使用中没有足够的例子。我想在我的http请求中使用它。如何正确显示隐藏/显示微调框?
public getCars(){
this.spinner.show();
this.appService.getCars().subscribe(
car => {
this.carList=car;
for (let i = 0; i < this.carList.length; i++) {
let make = this.carList[i].make;
}
},
);
this.spinner.hide();
}
我安装了ngx-spinner并正确导入了它。该库正在运行,但是我无法在我的http请求中正确使用它。 欢迎任何帮助。
答案 0 :(得分:2)
我认为您必须移动“ this.spinner.hide();”直接在“ for”语句的右括号下。这是成功回调。
答案 1 :(得分:0)
尝试一下:
public getCars(){
this.spinner.show();
this.appService.getCars().subscribe(
car => {
this.carList=car;
for (let i = 0; i < this.carList.length; i++) {
let make = this.carList[i].make;
}
this.spinner.hide();
},
);
}