Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

md-dialog still does not work with $q.all() #6719

Closed
philippbussche opened this issue Jan 17, 2016 · 3 comments
Closed

md-dialog still does not work with $q.all() #6719

philippbussche opened this issue Jan 17, 2016 · 3 comments
Labels
P4: minor Minor issues. May not be fixed without community contributions.
Milestone

Comments

@philippbussche
Copy link

Hi,
I am trying to show a dialog with a progress circle while data loads and automatically hide the dialog again after data has arrived. I found the solution of a gentleman who reported the usage of $q only to be working in angular material 0.10.x and below (#3919). What he built would be exactly what I am after.
The issue is marked as fixed but when I tried with a recent version then this still does not seem to work. Please see my codepen: http://codepen.io/anon/pen/EPwpKe - the dialog never closes.
Are there any other ways how to open and close a dialog after data loading has finished ?
Thanks
Philipp.

@Emeegeemee
Copy link
Contributor

My guess is that it has something to do with the promises resolving in the same digest cycle as opening the dialog. I modified your codepen by wrapping the promises in a timeout and it seems to work as you want it to.

@philippbussche
Copy link
Author

Thanks @Emeegeemee. I took your changes over into my app and it is now working as I am expecting it. I am pasting my Controller source below if anybody else ever needs something similar. As you can see I am querying data via a factory and as soon as thats there I am closing my dialog again. I am still new to Angular so one of the things I currently dont yet understand is why I have to specify the promise I get back from the factory call with $promise in my return function as this is different in the codepens but if I don't do that it just won't work meaning that the Dialog hide is executed immedeatly.
Thanks again for your help on this !

    myControllers.controller('ResultsCtrl', ['$scope', 'DialogFactory', '$q', '$timeout', 'Cities',
    function ($scope, DialogFactory, $q, $timeout, Cities) {

    DialogFactory.show("Loading cities...");
    $q.all([fetchCities()]).
         then(function(result) {
            DialogFactory.hide();
    });

    function fetchCities() {
        $scope.cities = Cities.query();
        return $timeout(function() {return $scope.cities.$promise;});
    }

    }]);

@ThomasBurleson ThomasBurleson added the P4: minor Minor issues. May not be fixed without community contributions. label Jan 18, 2016
@ThomasBurleson ThomasBurleson added this to the Backlog milestone Jan 18, 2016
@ThomasBurleson ThomasBurleson modified the milestones: Backlog, Deprecated Apr 20, 2016
@ThomasBurleson
Copy link
Contributor

This issue is closed as part of our deprecation effort.
For details, see our post Spring Cleaning 2016.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4: minor Minor issues. May not be fixed without community contributions.
Projects
None yet
Development

No branches or pull requests

3 participants