Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  7] [ 5]  / answers: 1 / hits: 17944  / 10 Years ago, mon, september 8, 2014, 12:00:00

I have a controller that creates a dialog with ngDialog.open. I assign scope:$scope and set scope variables with ng-model in the popup $dialog. However the values are not set in the controller $scope. The ng-click function is able to call a function in the $scope.



Is there something I am missing, I have searched quite a bit on here and github, read the docs and worked with all the examples provided on github in the project.



JS Fiddles below explains. It shows that the scope:$scope is not what it seems for .open(). It is a one way binding and does not go back to $scope. .openConfrm() seems to have the expected behavior.



ngDialog.open() - http://jsfiddle.net/s1ca0h9x/ (FIXED!! works like expected)



ngDialog.openConfirm() - http://jsfiddle.net/tbosLoa9/ (works as expected)



var myApplication = angular.module('myApplication', ['ngDialog']);

myApplication.controller('MainController', function ($scope, ngDialog) {
$scope.FormData={newAccountNum:''};
$scope.ShowNgDialog = function () {
ngDialog.open({
template: '<div><input type=text ng-model=FormData.newAccountNum/></div>',
plain: true,
scope:$scope

});
}


});


More From » angularjs

 Answers
4

I have edited the original post and added it below. The FIXED link shows it working and the second shows it broken. Adding a dot (using a javascript object) fixes the problem.



ngDialog.open() - http://jsfiddle.net/s1ca0h9x/ (FIXED!! works like expected)



ngDialog.openConfirm() - http://jsfiddle.net/tbosLoa9/ (works as expected)



var myApplication = angular.module('myApplication', ['ngDialog']);

myApplication.controller('MainController', function ($scope, ngDialog) {
$scope.FormData={newAccountNum:''};
$scope.ShowNgDialog = function () {
ngDialog.open({
template: '<div><input type=text ng-model=FormData.newAccountNum/></div>',
plain: true,
scope:$scope

});
}
});

[#69541] Friday, September 5, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jailynbethanies

Total Points: 686
Total Questions: 119
Total Answers: 99

Location: Cook Islands
Member since Thu, May 21, 2020
4 Years ago
;