0

I want to reload the page with different html page using angularjs $window, the documation says:

Page reload navigation The $location service allows you to change only the URL; it does not allow you to reload the page. When you need to change the URL and reload the page or navigate to a different page, please use a lower level API, $window.location.href.

So I set the loaction to the page $window.location.href = '/transaction';

and the matching route on config block:

app.config(function($routeProvider) {
    $routeProvider
    .when('/transaction', {
        templateUrl : 'JavaScript/directives/modelHTML/Transaction.html',
        controller : 'endProcessModelController'
    });
});

But instrad of Transaction.html page I get Error 404: SRVE0190E: File not found: /transaction with the route mydomain.com/UI/transaction.

BTW - templateUrl url's works fine in other place like UImodel so the problam is the navigation I think.

Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114
  • Please refer stackoverflow link : [angularjs-how-can-i-do-a-redirect-with-a-full-page-load](https://stackoverflow.com/questions/16002984/angularjs-how-can-i-do-a-redirect-with-a-full-page-load) – IftekharDani Jul 23 '17 at 11:16

3 Answers3

1

Set the location to the page $window.location.href = '#/transaction'; . '#' indicating location the startpage which is normally index.html. so the link will be index.html#/transaction.Since its a single page app

i think in your config do

'/UI/transaction'  instead of  `/transaction`

and in the link do $window.location.href = '#/UI/transaction'

henrybbosa
  • 1,139
  • 13
  • 28
0

Try this

$location.path($window.location.origin +'/transaction');

And if you feel all the routes have something extra after the origin you can set a <base href="..."> for that and tell angular from where to take the rest amount of text for route purpose.

If you redirect the page with your_origin/transaction your browser will make a request to the server of /transaction, which the server will be not able to understand and 404 will come. But the route is client side (browser) routeing, so If you are routing to route /abc your javascript code is interpreting that, and invokes the corrosponding operations, (might be a different call to server for the html template or some data dependency, and then instantiating the controller and attach to view). So the moment you are trying to route your javascript code should be loaded.

Either you go for a ui-router where the route comes after # and this allow the browser to play after the text of (#) and not to reloading.

Or, make your server such a way, If a unidentified request comes you should return the base (index) page, so it will load all the scripts and that js will do the rest. (But obviously you will loose all the existing data in that state)

Koushik Chatterjee
  • 4,106
  • 3
  • 18
  • 32
0

Is the mydomain.com/UI/transaction address correct (you use html5 mode)?

Does the problem occur when you try to enter directly into mydomain.com/UI/transaction?

If so, the problem is wrong server configuration (eg .htaccess file).

mod3st
  • 11
  • 2