使用jsstore获取indexeddb数据,其中where条件是过滤数据并且在返回为promise时,我无法绑定组件中的数据 我的服务代码
GetArticleByIdFromIndexedDB=function(id,section)
{let dbName:string;
dbName=this.GetUrlAndDB(section,false,true);
return new Promise<Article>
((resolve,reject)=>this._connection.select({
From:dbName,
Where:{
ArticleId:id
}
},function(res)
{
resolve(res);
},
function(err)
{
reject(err);
}
));
在组件中调用
this._service.GetArticleByIdFromIndexedDB(this.id,this.section).then(res=>
{
this._articleDetail.ArticleId=res.ArticleId;
this._articleDetail.HeadLine=res.HeadLine;
this._articleDetail.Abstract=res.Abstract;
this._articleDetail.ImageLink =this._article[0].ImageLink;
}).catch(err=>{console.log(err);});
在html中绑定
<img class="img-responsive" [src]="_articleDetail?.ImageLink" >
<div class="img-hr-new"></div>
<a [routerLink]="['/articledetail',_articleDetail?.ArticleId]"><h4>{{_articleDetail?.HeadLine}}</h4></a>
<p>{{_articleDetail?.Abstract}}</p></div>
</div>