Value is not binding with scope's variable if used inside uib-tabset

后端 未结 2 1531
旧巷少年郎
旧巷少年郎 2021-01-04 14:12

Value is not binding with scope\'s variable if used inside uib-tabset. Here in following example I tried to get $scope.message inside uib-tab and outside of it

相关标签:
2条回答
  • 2021-01-04 14:44

    Basically in angular, if you bind to a primitive the value of the variable is passed around, and not the reference to it, which can break 2-way binding. I'm guessing that the tabset directive creates its own scope, so the valueInScope variable defined in the controller loses its binding in the child scope of the tabset because its a primitive.

     $scope.data = {message:'my message'}
    

    Solution by Object

    also you can use $parent.parentproperty to bind child scope. This will prevent the child scope from creating its own property.

    Solution by using $parent

    0 讨论(0)
  • 2021-01-04 15:03

    You can solve this issue by creating an object on the scope and then adding the property on object instead of the scope inside the controller.

      $scope.obj = {message : 'my message'};
    

    You can verify this in the below plunker link

    http://plnkr.co/edit/3koAJnkOyf6hfGwO6AuD?p=preview

    0 讨论(0)
提交回复
热议问题