Angular UI router sub states not working on IE

雨燕双飞 提交于 2019-12-13 06:18:36

问题


As I said in my other question, I'm creating a webapp in AngularJS with NodeJS, Express and Angular-UI-Router.

At first I couldn't get the page to load at all (I managed to solve that problem), now the issue is that Angular-UI-Router doesn't seem to be able to go to nested states.

Note that this is a problem only on Internet Explorer. The website works perfectly on Chrome and Firefox. I'm using Internet Explorer 11.

"Regular" states work fine, but I can't access nested states (it doesn't throw any error though)

May it be because I use HTML5 no-hash URLs?

This is my index:

<!DOCTYPE html>
<html>
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
        <!-- Angular Material CSS now available via Google CDN; version 1.0.7 used here -->
        <link rel="stylesheet" href="./modules/angular-material/angular-material.min.css"/>
        <link rel="stylesheet" href="./css/style.css"/>
        <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/>
    <link rel="icon" href="icons/favicon.ico" type="image/x-icon"/>
        <base href="/"/>
        <title>Area Clienti</title>
        <script src="./modules/angular/angular.js" type="text/javascript"></script>

        <script src="./modules/ngstorage/ngStorage.js" type="text/javascript"></script>

        <script src="./modules/angular-aria/angular-aria.min.js" type="text/javascript"></script>
        <script src="./modules/angular-animate/angular-animate.min.js" type="text/javascript"></script>

        <script src="./modules/angular-material/angular-material.min.js" type="text/javascript"></script>

        <script src="./modules/angular-ui-router/release/angular-ui-router.min.js" type="text/javascript"></script>
        <script src="./modules/ui-router-extras/release/modular/ct-ui-router-extras.core.min.js" type="text/javascript"></script>
        <script src="./modules/ui-router-extras/release/modular/ct-ui-router-extras.dsr.min.js" type="text/javascript"></script>
        <script src="./modules/ui-router-extras/release/modular/ct-ui-router-extras.sticky.min.js" type="text/javascript"></script>

        <script src="./modules/pdfmake/build/pdfmake.min.js" type="text/javascript"></script>
        <script src="./modules/pdfmake/build/vfs_fonts.js" type="text/javascript"></script>

        <script src="./modules/angular-messages/angular-messages.min.js" type="text/javascript"></script>
        <script src="http://ngmaterial.assets.s3.amazonaws.com/svg-assets-cache.js" type="text/javascript"></script>

        <script src="./js/client.js" type="text/javascript"></script>
    </head>
    <body ng-app="App" ng-controller="AppCtrl" ng-view ui-view ng-cloak layout="row">
    </body>
</html>

This is the js config for ui-router states:

app.config(function($locationProvider, $mdThemingProvider, $mdIconProvider,$stateProvider, $urlRouterProvider, $stickyStateProvider) {
        $locationProvider.html5Mode(true);

        $mdThemingProvider
            .theme('default')
            .primaryPalette('blue')
            .accentPalette('light-blue');

        $urlRouterProvider.otherwise('/login');

        //$stickyStateProvider.enableDebug(true);

        $stateProvider
            .state('login', {
                url: '/login',
                templateUrl: 'views/login.html',
                controller:'loginController',
                authenticate: false
            })
            .state('dashboard', {
                url: '/',
                templateUrl: 'views/dashboard.html',
                controller:'dashboardController',
                authenticate: true,
                sticky:true,
                dsr:true
            })
            .state('dashboard.rating', {
                url:'rating',
                templateUrl: 'views/rating.html',
                controller: 'ratingController',
                authenticate: true,
                abstract:true
            })
            .state('dashboard.rating.search', {
                url:'/search',
                views: {
                    'top': {
                        templateUrl: 'views/rating-search.html'
                    },
                    'content':{
                        templateUrl:'views/rating-search-result.html'
                    }
                },
                authenticate: true
            })
            .state('dashboard.rating.view', {
                url:'/view',
                views: {
                    'top': {
                        template: ''
                    },
                    'content':{
                        templateUrl:'views/rating-view.html'
                    }
                },
                authenticate: true
            })
            .state('dashboard.infocamere', {
                url:'infocamere',
                templateUrl: 'views/in-costruzione.html',
                authenticate: true
            })
            .state('dashboard.pratiche', {
                url:'pratiche',
                templateUrl: 'views/in-costruzione.html',
                authenticate: true
            });
    })

回答1:


Add this in meta tag

 <meta http-equiv="X-UA-Compatible" content="IE=edge">

This can be considered equivalent to HTML5 doc-type which asks the browser to run in the doc in most supported mode from IE 11 to IE 6 Edge is the most supported document mode in IE

For more information about this one can read this thread https://github.com/google/web-starter-kit/issues/728



来源:https://stackoverflow.com/questions/42084330/angular-ui-router-sub-states-not-working-on-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!