javascript - Refresh data originally passed into modalInstrance in AngularJS -


angular - using UI bootstrap

I am passing data in a modal instrument like the below model In, users have the ability to create new items. On the Save button press, a new item is sent to the server. I need the ability to refresh the model instance with updated data from $ scope.items. I note, when saving the modal does not stop, so I can not open it again. Any help would be greatly appreciated.

  $ scope.items = ['item1', 'item2', 'item3']; $ Scope.open = function (size) {var modalInstance = $ modal.open ({templateUrl: 'myModalContent.html', Controller: 'ModalInstanceCtrl', solve: {item: function () {return $ scope.items;} }}); ModalInstance.result.then (function () {// Post Update $ scope.items // Get fresh $ scope.items from server // Notify modal of updated items}, function () {}); }; });  

You try to create a scope for your $ modalInstance $ scope :

  var modalInstance = $ modal.open ({templateUrl: 'myModalContent.html', Controller: 'ModalInstanceCtrl', scope: $ scope}); Now after adding some  items  to your  item , everything will work properly, then  

.

For more information, see the description of the $ modal instruction on :

scope - the content of the modal A scope example to use for (In fact the $ modal service is going to create a child's scope of a given scope). $ Root Default

Demo:

Hope this will solve your problem;)


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -