【发布时间】:2018-08-14 16:03:22
【问题描述】:
我有这个模型:
export class Photo{
constructor(
public users_id: number,
public photo: Blob
) { }
}
还有这样的服务:
import {Injectable} from '@angular/core';
import {Photo} from '../../models/photo.model';
import {handleError} from "../../shared/functions";
import { AuthService } from '../auth/auth.service';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class PhotoService{
constructor(
private _authService:AuthService
){
}
getPhotos(){
return this._authService.get('photos')
.map(res => res.blob())
.map(blob => URL.createObjectURL(blob))
.toPromise();
}
}
这里是授权用户过滤器上传的图片:
private loadPhotos() {
let filteredPhotos;
if (this.servPhoto) {
this.servPhoto.getPhotos().subscribe(photo => {
if(!this.authService.currentUserData) { return; }
this.photos = photo;
this.filteredPhotos = this.photos.filter((photo) => photo.users_id == this.authService.currentUserData.user_id);
});
}
}
我得到这样一个错误:
/home/admin/Desktop/project/frontend/src/app/layout/pages/profile/profile.component.ts 中的错误 (79,36): 类型上不存在属性“订阅” '承诺'。
告诉我如何正确实现下载。
【问题讨论】:
标签: angular