typescript - 当我只有一个实例时,Typescript observable 永远不会更新
问题描述
我在这个问题上工作了很多天,但我从来没有发现为什么我的 observable 不起作用:当修改出现时它没有更新..我尝试使用其他 http 请求,但我遇到了同样的问题。
当有新的修改时,如何更新我的角度组件中的数据?
服务 :
@Injectable({
providedIn: 'root'
})
[...]
getAllCodeBuildrun(projectCodebuildName : string): Observable<Response>{
return this._http
.get(environment.baseURL + "/codebuildProject/"+projectCodebuildName+"/buildRun")
// ...and calling .json() on the response to return data
.map((res:Response) => res.json())
//...errors if any
.catch((error:any) => Observable.throw(error || 'Server error'));
}
零件:
@Component({
selector: 'app-application',
templateUrl: './application.component.html',
styleUrls: ['./application.component.css']
})
[...]
ngOnInit() {
this.applicationsService.getAllCodeBuildrun("test").subscribe(
buildsRun => {
console.log('codeBuild :', buildsRun); // appear just one time in console
this.builds= buildsRun["builds"];
},
error => console.error('error', error)
);
}
应用程序模块.TS
providers: [
ProjectsService
],
解决方案
推荐阅读
- javascript - 输入内的 SVG 与粘贴的长文本重叠
- java - 我无法使暗/亮模式切换正常工作
- python - 如何在 django 中使用 panda 来规范化下面的 json
- sms - 在 vb.net 中使用 smart bro 插件发送批量短信
- flutter - 如何获取购物篮中所有商品的总价
- azure-data-explorer - 使用 kusto 查询语言每天或每月关闭多个虚拟机多长时间
- python - SQLAlchemy - 将动态表名传递给查询函数?
- visual-studio - 使用 Visual Studio 2019 进行调试时,dockerized lagacy NET 框架项目的命令行参数
- php - 如何将离子视频捕获移动到 php 中的 file_put_contents()
- mongodb - Mongodb shell find 过滤提取嵌入文本数据