down votefavorite 
<http://stackoverflow.com/questions/41445739/on-bootstrap-modal-refresh-keep-my-json-data-in-current-modal-view/41447345#>

In my Angular app my Bootstrap modal opens up with a custom url, set using 
ui-router. The problem I have is on page refresh my JSON data gets cleared 
from my modal and it displays empty. Any help on how to retain the data on 
page refresh?

Link to my site: http://wingfield.vmgdemo.co.za/

My code:


 // configure the stateProvider
app.config(['$stateProvider', '$urlRouterProvider',
    function ($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise('/showroom');
        $stateProvider
        // define home route "/"
            .state('showroom', {
                url: '/showroom',
                templateUrl: 'partials/showroom.html'
            })
            // define modal route "/modalDetails"
            .state('modalDetails', {
                url: '/modalDetails/',
                params: {
                    car: null
                },
                onEnter: ['$stateParams', '$state', '$uibModal',
                    function ($stateParams, $state, $uibModal) {
                        $uibModal
                        // handle modal open
                            .open({
                                templateUrl: 'partials/modalDetails.html',
                                resolve: {
                                    car: function () {
                                        return $state.params.car
                                    }
                                },
                                controller: ['$scope', '$location',
                                    function ($scope, $location) {
                                        // handle after clicking Cancel button
                                        $scope.car = $state.params.car;
                                        $scope.cancel = function () {
                                            $scope.$dismiss();
                                        };
                                        // close modal after clicking OK button
                                        $scope.ok = function () {
                                            $scope.$close(true);
                                        };
                                    }
                                ]
                            })
                            // change route after modal result
                            .result.then(function () {
                            $state.transitionTo('showroom');
                        }, function () {
                            $state.transitionTo('showroom');
                        });
                    }
                ]
            });
    }]);

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to