AngularJS passes data from modal

I would be grateful for the help here ... I am considering using AngularJS for several projects that I have in mind. He is currently experimenting with the UI Bootstrap directive. Please see my code here: http://pastebin.com/zJGpNLep

Is there a way so that I can update $ scope.groups with data from $ scope.formData that is generated from modal? I tried $ scope.groups.push ($ scope.formData), which turned out to be unsuccessful, and only I see new data, refreshing the page.

Any ideas?

thanks

+4
source share
2 answers

You are on the right track, you just left these lines:

modalInstance.result.then(function (formData) {
  //use formData
});

$scope.showAddGroupModal, :

$scope.open = function () {

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

  modalInstance.result.then(function (selectedItem) {
    $scope.selected = selectedItem;
  }, function () {
    $log.info('Modal dismissed at: ' + new Date());
  });
};
+5

, . , , . , , .

:

var modal = $modal.open({
   // modal setup
});

modal.result.then(function(group) {
    $scope.groups.push(group)
}, function () {
   // the modal was dismissed
});

, .

+1

Source: https://habr.com/ru/post/1523750/


All Articles