zoukankan      html  css  js  c++  java
  • 点击编辑,进入编辑页面并把值渲染到页面上

    1.

    //服务中
    //获取测验列表
        getListData(): Promise<FormData[]>{
            console.log(this.listUrl)
           return this.http.get(this.listUrl)
           .toPromise()
           .then(response => {
                console.log(response.json().data)
               return response.json().data as FormData[];
                
           })
           .catch(this.handleError)
        }
    
        //获取单个测验信息
        getTest(id: number): Promise<FormData> {
            return this.getListData()
                       .then(test => test.find(data => data.id == id));
                      
          }

    2.编辑页面中

      ngOnInit(): void {
        this.route.paramMap
          .switchMap((params: ParamMap) =>{
              return this.dataService.getTest(+params.get('id'))
          }).subscribe((data)=>{
            this.item = data;
          });
      }

    3.引入

    import { ActivatedRoute, ParamMap } from '@angular/router';
    
    // 构造
      constructor(
        private dataService: DataService,
        private route: ActivatedRoute,
        private location: Location,
      ) {
     
      }
  • 相关阅读:
    平面点集最佳平面
    快速变幻AABB的顶点
    惯性坐标系
    Grapher
    Grapher
    射线到直线方程的转换
    两个运动球的相交性测试
    射线和球的相交性
    Glow Shader
    Shder中实现TintColor
  • 原文地址:https://www.cnblogs.com/linsx/p/8331649.html
Copyright © 2011-2022 走看看