Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Make parent form aware of child form ng-dirty state chan
Message
 
 
À
17/08/2015 13:28:35
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01623431
Message ID:
01623517
Vues:
42
UPDATE. Got help on that problem in StackOverflow http://stackoverflow.com/questions/32059445/struggling-with-asynchronous-nature-of-angularjs-javascript so that solution works. I don't like it as I had to add code to controller instead of using directive and the same approach as other forms are using.

I almost got it to work based on your earlier suggestion of adding a watch.

Right now I have the following code:
var testNavigation = function()
            {                
                if ($scope.selections.somethingChanged) {
                    
                    var modal = $modal.open({
                        controller: function ($scope) {
                            $scope.okClass = 'btn-primary',
                            $scope.okLabel = resourceFactory.getResource('Labels', 'yes'),
                            $scope.cancelLabel = resourceFactory.getResource('Labels', 'cancel'),
                            $scope.title = resourceFactory.getResource('Labels', 'unsavedChanges'),
                            $scope.message = resourceFactory.getResource('Messages', 'unsavedChanges');
                        },
                        templateUrl: '/app/templates/modal'
                    });

                    modal.result.then(function () {
                        
                        $scope.selections.somethingChanged = false;
                        return false;
                        
                    });
                }
                
            }

            $scope.loadView = function (guest) {
                testNavigation();
                if ($scope.selections.somethingChanged)
                {
                    return false;
                }

              more code here
The problem is that the execution is not sequential, e.g. it passes testNavigation, goes down to return false and after that I see my modal dialog. So, even if I answer 'Yes' on that question my new row is not loaded. So, I am now dealing with the asynchronous nature of the code. I am very close, can you see what I need to change in the above to make it work?

Thanks again.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform