$location

12 views
Skip to first unread message

Paul Knaggs

unread,
May 29, 2015, 1:31:44 PM5/29/15
to ang...@googlegroups.com
Hi I am looking for help with a hybrid web app 
The format is on a php dynamic template 
I have coded in a Angular splash screen that works well but when I open a linked page on return it refreshes and the splash screen rerenders.
This is the code I am using right now, is there an alternative so the page does not refresh on return.


the two links below work from ng-click

                    var _gaq = _gaq || [];
                    var app = angular.module('landingApp', []);
                    app.config(function($locationProvider) {
                        // use the HTML5 History API
                        $locationProvider.html5Mode(true);
                    });

                    app.controller('landingController', function($scope, $window) {

                        $scope.goto_viewdetail = function(item) {
                            $window.location = '/viewdetail.php?qrcode='+item;
                        };
                        $scope.goto_sendemail = function(item) {
                            $window.location = '/sendemail.php?qrcode='+item;
                        }
                    });
                

Sander Elias

unread,
May 29, 2015, 2:28:07 PM5/29/15
to ang...@googlegroups.com
Hi Paul,

Setting $windows.location will cause a browser refresh, so unless you are storing some state info into a persistent storage(cookie/localStorage/indeDB/..), your app will get's completely reinitialized.
I think you need to use the $location service instead.

Regards
Sander


Paul Knaggs

unread,
May 30, 2015, 10:43:15 AM5/30/15
to ang...@googlegroups.com
Thanks for your reply I have tried $location unfortunately it won't work with my setup,
But thanks for the advice I am still working on it but have decided to try a different method I will scrap the linked page and place it's content in a div with ng-view or show and hide from ng-click.

Reply all
Reply to author
Forward
0 new messages