Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting window.location.href takes a long time
Message
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01626184
Message ID:
01626539
Vues:
46
>I guess there might be a bit of overhead when using angular - but surely most of the delay will be in pulling the page over the wire.
>Also angular knows nothing about the action if you use window.location.href (which may, or may not, be a problem)

Well if you navigate to a route that shouldn't be a problem. You can use $location instead and that will cause an Angular digest cycle, but not really necessary on navigation in most cases unless you use non-routed navigation.

My point though is that window.location will change immediately - that's not going to be slow. Re-rendering a new route/controller/view though that can definitely be slow.

As always saying something is slow without instrumenting and figuring out exactly WHAT is slowing down is a fool's errand.It's easy enough to see the timings in the dev tools profiler or by putting a few strategic console.log() statements in place.

+++ Rick ---
>
>
>>
>>>>Hi everybody,
>>>>
>>>>I have a single page form. In the Cancel method of this form I tried the following code (I've added last line of code just now):
>>>>
>>>>
>>>>$scope.cancel = function () {
>>>>                $scope.form.$setPristine();
>>>>                $scope.showForm = false;
>>>>                window.location.href = "/";
>>>>            };
>>>>
>>>>It works but with a considerable delay. E.g. the form disappears, but the URL changes only after about 20+ seconds to the localhost. Is there a better way to apply similar functionality? E.g. I simply want to re-set the current view to point to nothing as we "closed" that form by pressing 'Cancel'.
>>>>
>>>>The top of my controller has the following:
>>>>
>>>>
>>>>(function () {
>>>>    'use strict';
>>>>
>>>>    var app = angular.module('sysMgrApp');
>>>>
>>>>    app.config(['$stateProvider', function ($stateProvider) {
>>>>        $stateProvider.state('home', {
>>>>            url: '/',
>>>>            controller: 'prefsAcsCrudController',
>>>>            template: ''
>>>>        }).state('accountUDFs', {
>>>>            url: '/AccountUDFs',
>>>>            templateUrl: 'customerAccounts/PrefsAcs/AccountsUDFs'
>>>>        }).state('invoiceUDFs', {
>>>>            url: '/InvoiceUDFs',
>>>>            templateUrl: 'customerAccounts/PrefsAcs/InvoiceUDFs'
>>>>        }).state('confirmationText', {
>>>>            url: '/ConfirmationText',
>>>>            templateUrl: 'customerAccounts/PrefsAcs/ConfirmationText'
>>>>        });
>>>>    }]);
>>>>
>>>>The problem I am trying to solve I described in another thread and this StackOverflow thread:
>>>>
>>>>http://stackoverflow.com/questions/33109910/how-to-reload-page-angularjs
>>>>
>>>>E.g. I go to one page form from the Favorites menu, I then press 'Cancel', then I try to open that same form again (it's supposed to go to that same URL) and then nothing happens besides spinning wheel image. My idea is to go to some place else (best to the /) so the Favorites menu will work (and it does work with that).
>>>>
>>>>Thanks in advance.
>>>
>>?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform