angular ui modal can NOT refer to parent scope

后端 未结 3 1803
悲哀的现实
悲哀的现实 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:51

    You'll need to refer to the parent scope in your $modal options. Angular documentation

    Corrected Plunker Version

    Below is also a code snippet of what I added to make it work.

    var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: ModalInstanceCtrl,
      scope:$scope, //Refer to parent scope here
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });
    

提交回复
热议问题