从"Blog"仓库中分离出来
This commit is contained in:
24
index/src/app/services/count/count.service.ts
Normal file
24
index/src/app/services/count/count.service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpService} from '../http.service';
|
||||
import {Count} from '../../class/count';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CountService {
|
||||
|
||||
constructor(public http: HttpService) {
|
||||
}
|
||||
|
||||
count: Count;
|
||||
|
||||
getCount() {
|
||||
const observable = this.http.get('/counts');
|
||||
observable.subscribe((data: any) => {
|
||||
if (data.code === 0) {
|
||||
this.count = data.result;
|
||||
}
|
||||
});
|
||||
return observable;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user