我试图在单击按钮时创建一个微调器,但它似乎没有运行,这就是我在 component.html 中所做的
<button type="submit" class="btn btn-accent btn-block btn-flat b-r-10" style="background: #FF473A;">
Sign In
<i class="fa fa-spinner fa-spin" *ngIf="loading"></i>
</button>
Run Code Online (Sandbox Code Playgroud)
并在 component.ts 中
export class LoginComponent implements onInit {
private loading: boolean;
//form ngSubmit function()
login() {
if (this.user.email, this.user.password) {
this.loading = true;
this.userSrv.login(this.user.email, this.user.password); //api call here
this.loading = false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
好的,我的服务.ts
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import { Router } from '@angular/router';
import { Globals } …Run Code Online (Sandbox Code Playgroud)