ngBootbox icon indicating copy to clipboard operation
ngBootbox copied to clipboard

Issue with updating $scope using callback function

Open Parthvora opened this issue 9 years ago • 3 comments

Hello,

I want to update a $scope variable in a bootbox callback function. Like:

HTML:

< h1>{{msg}}< /h1>

JS:

$scope.msg = "old message"; $scope.customizeTableBootboxOption = { scope: $scope, buttons: { success: { label: 'Save', className: 'btn-success', callback: function () { $scope.msg = "new message"; }); } } };

When I submit that "Save" button from pop up, that message still remains "old message" instead of "new message", but when I open that bootbox pop up again, that message automatically updates to "new message". I have already tried with and without option "scope: $scope", but nothing changes.

Thanks in advance.

Parthvora avatar Feb 02 '16 13:02 Parthvora

+1

jexneedls avatar Mar 17 '16 15:03 jexneedls

I had the same exact problem. Ended up doing this and it worked:

$scope.$apply(function() {
    $scope.var = 'new value';
});

asentner avatar Mar 23 '16 14:03 asentner

I think this should be fixed ASAP. I use callbacks everywhere and always have to wrap code into $scope.$apply.

Ivan-Perez avatar Jun 20 '17 09:06 Ivan-Perez