Skip to content

Commit

Permalink
Merge pull request likeastore#69 from laurynas-karvelis/master
Browse files Browse the repository at this point in the history
Fixes ngDialogData being passed *AFTER* controller instantiation
  • Loading branch information
voronianski committed Sep 2, 2014
2 parents 77868be + 711a6fd commit d5e21bc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions js/ngDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@

self.$result = $dialog = $el('<div id="ngdialog' + globalID + '" class="ngdialog"></div>');
$dialog.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">' + template + '</div>');

if (options.data && angular.isString(options.data)) {
var firstLetter = options.data.replace(/^\s*/, '')[0];
scope.ngDialogData = (firstLetter === '{' || firstLetter === '[') ? angular.fromJson(options.data) : options.data;
} else if (options.data && angular.isObject(options.data)) {
scope.ngDialogData = angular.fromJson(angular.toJson(options.data));
}

if (options.controller && (angular.isString(options.controller) || angular.isArray(options.controller) || angular.isFunction(options.controller))) {
var controllerInstance = $controller(options.controller, {
Expand All @@ -174,13 +181,6 @@
$dialog.addClass(options.className);
}

if (options.data && angular.isString(options.data)) {
var firstLetter = options.data.replace(/^\s*/, '')[0];
scope.ngDialogData = (firstLetter === '{' || firstLetter === '[') ? angular.fromJson(options.data) : options.data;
} else if (options.data && angular.isObject(options.data)) {
scope.ngDialogData = angular.fromJson(angular.toJson(options.data));
}

if (options.appendTo && angular.isString(options.appendTo)) {
$dialogParent = angular.element(document.querySelector(options.appendTo));
} else {
Expand Down

0 comments on commit d5e21bc

Please sign in to comment.