two way binding with safe navigation operator

前端 未结 2 498
迷失自我
迷失自我 2020-11-27 06:39

What is the best way to use two-way-binding (syntax-sugar) in Angular 2 with the safe navigation operator. I\'ve tried the following.



        
2条回答
  •  我在风中等你
    2020-11-27 07:18

     {{x?.y?.z}}
    
    export class ParentCmp {
      x={y:{z:"a"}}
       changeMe(val)
        {
          console.log(val);
          this.x.y.z=val;
        }
    }
    

    http://plnkr.co/edit/ZBeSPqf4HUwLOeWSNfZJ?p=preview

提交回复
热议问题