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

后端 未结 2 1556
旧巷少年郎
旧巷少年郎 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

提交回复
热议问题