C
C
cvbcvb cvbcvbcvbcvb2016-07-07 00:49:58
PHP
cvbcvb cvbcvbcvbcvb, 2016-07-07 00:49:58

Why is the State ui-router reset on page reload?

Hello everyone
, I'm terribly dumb. I can’t solve the problem all evening
the application is written in angular + php
Routing took over angular
doing the admin panel.
Here is the file in which the routing is configured purely for the admin
panel Login to the admin panel and the panel itself

angular.module('adminAtom', ['ui.router'])
.config(function($stateProvider, $locationProvider, $httpProvider){
  $httpProvider.defaults.headers.delete = { 'Content-Type' : 'application/json' };
    $stateProvider
        .state('adminPanel', {
            url: '/admin/panel',
            templateUrl: 'admin/views/goods.html',
            controller: 'goodsCtrl',
            controllerAs: 'goods'
        })

        .state('adminLogin', {
            url: '/admin/',
            templateUrl: 'admin/views/login.html',
            controller: 'loginCtrl',
            controllerAs: 'login'
        })
        $locationProvider.html5Mode(true);
})

Why is it that when I open the admin panel,
index.html is loaded, which is in the admin folder
, everything is ok in it,
the corresponding view is loaded
and when I reboot everything is ok (well, it’s understandable)
and when I write in the address bar /admin/panel (the corresponding view should open)
it doesn't open
and php error: Cannot GET /admin/panel
BUT
when I'm just in the controller that is responsible for the login page (which opens by default) I write: $state.go('adminPanel')
Goes to this state
everything opens as needed, but when reloading the same error as before ( Cannot GET /admin/panel )
I understand that a request is being made and PHP is trying to open this page,
but damn...
how to make it normal
so that
everything works because of html5Mode?
with "#" everything will work?
but my whole main site is made without it, and when I turn off this html5Mode here, it still resets,
tell me what to do.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question