ngBootbox
ngBootbox copied to clipboard
Issue with updating $scope using callback function
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.
+1
I had the same exact problem. Ended up doing this and it worked:
$scope.$apply(function() {
$scope.var = 'new value';
});
I think this should be fixed ASAP. I use callbacks everywhere and always have to wrap code into $scope.$apply.