angularjs - ng-switch does not bind ng-model

前端 未结 3 1537
走了就别回头了
走了就别回头了 2020-11-29 07:48

I have this repro http://embed.plnkr.co/nVCmukG5abpi1Y4ZHkrq that show when I click \'Title3\' and enter a value in text box although the entered value shows reflected in th

3条回答
  •  长情又很酷
    2020-11-29 08:26

    I've encountered similar issue, and I've solved by creating a scope variable in the controller and used that with in ng-include and ng-switch. This way if you've deep nested ng-include's with in ng-switch and it goes on, we can still directly use that scope variable.

    As all child scopes (here, ng-include/ng-switch) extends from parent scope (generally, controllers scope), we can access parent scope directly from with in these child scopes without a problem.

    Using $parent will require to write like $parent.$parent.$parent.someProp

    Example Plunk: http://plnkr.co/edit/8UGH7nUpFmATiXfkYSwr?p=preview

提交回复
热议问题