angular ui modal can NOT refer to parent scope

后端 未结 3 1800
悲哀的现实
悲哀的现实 2021-02-08 03:21

i am using angular ui modal to create modal in my project.

Everything works fine until I need to refer to variable in parent scope. see plunker code

It seems lik

3条回答
  •  太阳男子
    2021-02-08 03:55

    You can add an ID to the parent div and use his scope.

    Outer Controller

    Value Of checkbind: {{checkBind}}

    And set up a "fake" binding within the controller

    //init
    $scope.checkBind = angular.element(document.getElementById('outerdiv')).scope().checkBind;
    
      $scope.$watch('checkBind', function (newValue, oldValue) {
    //update parent
      angular.element(document.getElementById('outerdiv')).scope().checkBind = $scope.checkBind;
      });
    

    See http://plnkr.co/edit/u6DuoHJmOctFLFhvqCME?p=preview

提交回复
热议问题