1、子component中的异步方法

initCreateJob = () =>
new Promise((resolve, reject) => {
setTimeout(() => {
this.spiderFormService.saveUserJob(this.spiderJobInfo).subscribe((res: Res) => {
if (res.code === 1) {
// val = res.data;
resolve(res.data)
// fn(this.spiderJobInfo.jobInfoId)
}else{
// 提交异常
reject("Error code: " + JSON.stringify(res))
}
});
}, 1000)
}
);

2、加载多个子组件

引入组件

<app-spider-form #test1></app-spider-form>
<app-image-check-form #test2></app-image-check-form>

3、父组件的component中引用子组件component

export class parentComponent implements OnInit,AfterViewInit{

// 引用子组件
@ViewChild('test1', {static: false}) test1;
@ViewChild('test2', {static: false}) test2; constructor() {
} ngOnInit() {
} ngAfterViewInit(){
// 子组件加载完毕触发
this.initSpiderJob();
} initSpiderJob(){ forkJoin([
from(this.test1.initCreateJob()).pipe(catchError(error => of(`Bad Promise: ${error}`))),
from(this.test2.initCreateJob()).pipe(catchError(error => of(error)))
])
.subscribe(results => {
console.log("results" + JSON.stringify(results))
});
} }

个人博客 蜗牛

最新文章

  1. 添加AppWidget功能
  2. C语言正则表达式详解 regcomp() regexec() regfree()详解
  3. rspec中的shared_examples与shared_context有什么不同
  4. PHP面向对象07_PDO
  5. git打tag 三步骤
  6. 外部按键 控制 LED 中断 (参考 http://www.oschina.net/question/565065_115196?sort=time )
  7. ASP.NET-【状态管理】-Cookie小结
  8. python匿名函数(lambda)
  9. DataGridView 的cell赋值没有线程间访问的限制吗?
  10. DataGuard相同SID物理Standby搭建
  11. Objective-c setObject:forKey:和setValue:forKey:的区别
  12. iOS 推荐博客
  13. 天天模拟器极速畅玩靠谱游戏《仙境传说RO:复兴》
  14. C++中怎样获取类成员的指针
  15. Python软件目录结构规范
  16. 2018-2019-2 网络对抗技术 20165319 Exp3 免杀原理与实践
  17. Linux&#160;学习笔记之超详细基础linux命令&#160;Part&#160;10
  18. [No0000F2]ip安全监视器
  19. shlve 模块
  20. OpenGL ES3 非常好的系列文章

热门文章

  1. 二叉树 B-树B+树
  2. Spring Cloud Feign 调用过程分析
  3. 动态查找之二叉树查找 c++实现
  4. Python示例项目学习
  5. Attribute application@allowBackup value=(true) from AndroidManifest.xml:7:9-35
  6. tensorflow keras analysis
  7. 运维笔记--给正在运行的Docker容器动态绑定卷组(挂载指定目录)
  8. macOS 10.15 Catalina xxx.app已损坏,无法打开,你应该将它移到废纸篓解决方法
  9. 浅入深出ETCD之【raft原理】
  10. python初级(302) 6 对象(一)