How to handle the first request in an Angular and

2019-07-19 16:14发布

I have a issue. My home state url is '/', but also in Django my home url is '/'

$stateProvider
.state("home",{
  url:"/",
  controller:'HomeController',
  resolve:{
    cities:getAvailbleCities
  },
})

My urls.py

url(r'^/*$', 'landing.views.landing', name='home'),

My base href

<base href="/">

So, when I visit localhost:8000/, angular catch the request, execute HomeController but my server also catch the request and it cause a redirect and the page is refreshed and all my changes inside HomeController are gone.

How should I handle the / url without making any conflict.

Or there is another way to fetch initial data from django server.

Note: I need in somehow reach the server, because I need django initial data(crsf cookies,etc). So removing url home rule does not work for me.

0条回答
登录 后发表回答