Javascript 角度UI路由器加载错误的控制器/模板

Javascript 角度UI路由器加载错误的控制器/模板,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,也许很简单,但这是我第一次使用。我正在使用html5模式,并已配置以下状态: $locationProvider.html5Mode(true); $authProvider.loginUrl = API_LOCATION + 'authenticate'; $urlRouterProvider.otherwise('/auth'); $stateProvider .state('auth', { url: '

也许很简单,但这是我第一次使用。我正在使用html5模式,并已配置以下状态:

    $locationProvider.html5Mode(true);

    $authProvider.loginUrl = API_LOCATION + 'authenticate';

    $urlRouterProvider.otherwise('/auth');
    
    $stateProvider
        .state('auth', {
            url: '/auth',
            templateUrl: TEMPLATES_LOCATION + 'login.html',
            controller: 'AuthController as auth'
        })
        .state('country', {
            url: '/country',
            templateUrl: TEMPLATES_LOCATION + 'country.index.html',
            controller: 'CountryListController'
        })
        .state('country.select', {
            url: '/select',
            templateUrl: TEMPLATES_LOCATION + 'country.select.html',
            controller: 'CountrySelectController'
        })
        .state('country.edit', {
            url: '/:isoCode',
            templateUrl: TEMPLATES_LOCATION + 'country.edit.html',
            controller: 'CountryEditController'
        });
所有国家/地区路线都加载
country.index.html
CountryEditController
。为什么?

编辑 my.htaccess文件(angular应用程序位于名为“admin”的子文件夹中)

重新编写引擎打开

#RewriteBase/admin/您是否尝试过
MYSITEURL/#/country
?我正在使用html5模式,忘了提到这一点。您需要向服务器添加htaccess(url重写)以确保其正常工作。我确信,如果您执行
country Link
,它将正常工作。htaccess的配置不正确。顺便说一句,您的第二条评论并不能解决浏览器页面刷新(这是一种常见的用户操作)问题。
RewriteEngine on

#RewriteBase /admin/ <- tried this too

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*) /admin/index.html [NC,L]