Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Canceling from the form and returning to the top level
Message
From
25/09/2016 04:14:17
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01641209
Message ID:
01641309
Views:
29
>So, if I have the following in the app.js
>
>
>//app.config(['$locationProvider', function ($locationProvider) {
>    //    $locationProvider.html5Mode(true);
>    //    $locationProvider.hashPrefix('!');
>    //}]);
>
>uncommented, then we loose the Specials/Specials part in URL when we go to a particular Edit page from the Index page.
>
>I had to comment these lines, but now $location.path('/') just adds # at the end of URL and doesn't strip Items/Preferences part as I want and as it works if I uncomment these lines above.
>
>http://localhost:9999/Items/Preferences#/
>
>
>Do you see a way to keep the $locationProvider to be default, but yet correctly adjust path in URL without a re-loading the page?

Might be wrong but I don't think it's possible. As per the docs Hashbang mode will reload the page. If switching to HTML5 mode gives only a couple of problems it might be best to work on correcting those in that mode ?

>
>>>>>>So $location.path() is returning an empty string ?
>>>>>>Not sure if it's relevant but are you using HTML5 or Hashbang mode ?
>>>>>>
>>>>>
>>>>>I didn't change anything for $locationProvider, e.g. I didn't set it (I am not sure I understood where the code is supposed to go). So, I assume we're using defaults.
>>>>
>>>>Default is Hashbang mode. Don't have time to check but behaviour is different to HTML5 mode. Read the relevant section in the link I posted earlier.
>>>>Also can you try setting $location.path() directly (i.e. not adapting the current $location.path() )
>>>>
>>>
>>>Tried the following, no luck:
>>>
>>>
>>> $scope.cancel = function () {
>>>            //var curPath = $location.path();
>>>            //$log.debug("Current Path: " + curPath);
>>>            //var newPath = curPath.replace("/RetailInventory/PrefsRetail", "/");
>>>            //$log.info("New Path: " + newPath);
>>>            $scope.form.$setPristine();
>>>            $scope.showForm = false; // close the form
>>>            $location.path('/');
>>>        };
>>>
>>>I'll try playing with $locationProvider.
>>
>>What do you mean by 'no luck' ? Does it not show the page at all or do you mean that it is still reloading the page? If it's reloading then it may be because you're in Hashbang mode. Snip:
>>
>>In this mode, $location uses Hashbang URLs in all browsers. Angular also does not intercept and rewrite links in this mode. I.e. links work as expected and also perform full page reloads when other parts of the url than the hash fragment was changed.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform