How to reload browser and and keep current state in AngularJS UI-Router? -


i built small web app use ui-router navigate pages. works fine apart of browser refresh or accessing specific page using state link. tried several solutions posted here on same topic non of them helped maybe due lack of additional information.

when click ui-sref link below, 'mysite/content' , page displays normally, once refresh or try access pasting link doesn't find page.

could please me make work expected. in advance.

html

<p ui-sref="content">link content</p> 

angularjs

var app = angular.module('myapp',['ui.router']);  app.config(['$stateprovider', '$urlrouterprovider', '$locationprovider', function($stateprovider, $urlrouteprovider, $locationprovider){       $urlrouteprovider.otherwise('/');       $stateprovider          .state('home', {             url: '/',             views: {                 '': { templateurl: '/app/templates/wrapper.html'},                 'nav@home': { templateurl: '/app/templates/nav.html'},                 'header@home': { templateurl: '/app/templates/header.html'},                 'footer@home': { templateurl: '/app/templates/footer.html'}             }         })          .state('content', {             url: '/content',             views: {                 '': { templateurl: '/app/templates/content.html'},                 'nav@content': { templateurl: '/app/templates/nav.html'},                 'header@content': { templateurl: '/app/templates/header.html'},                 'footer@content': { templateurl: '/app/templates/footer.html'}              }         });      $locationprovider.html5mode(true);   }]) 

with html5mode set true, when refreshing page, browser make request 'mysite/content'. in classical one-page-applications, back-end has set of routes respond data, , configured return application index.html other routes (for example 'mysite/content').

it works when disable html5mode because browser makes request url without part after '#', back-end returns expected index.html.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -