2016-09-14 128 views
0

這是我route.js路由類型錯誤:無法讀取屬性「html5Mode」

export default routesConfig; 


function routesConfig($stateProvider, $urlRouterProvider, $locationProvider) { 
    $locationProvider.html5Mode(true).hashPrefix('!'); 
    $urlRouterProvider.otherwise('/'); 
    $stateProvider 
    .state('login', { 
     url: '/', 
     component: 'login' 
    }) 
    .state('home', { 
     abstract: true, 
     url: '/home', 
     component: 'home' 
    }) 
} 

在我app.js和配置文件

angular.module('app', [ 
    uiRouter, 
    Login, 
    Home 
]) 
    .config(['$locationProvider'],routesConfig()) 

    .component('app', AppComponent); 

登錄和家庭是兩個模塊,每個模塊有與它相關的組件。

+0

你沒有'hashPrefix'試試嗎? – Weedoze

+0

在你的'app.js'文件中,你可以在調用'routesConfig()'時添加'$ locationProvider'作爲參數嗎? – ProfNandaa

+1

這應該是第三個參數。 –

回答

1

這裏的問題是你沒有按相同的順序指定函數所需的依賴參數。

您必須按照與函數定義中相同的順序注入參數。

因此,在您的app.js中,您必須以相同的順序指定注入參數。

angular.module('app', [ 
    uiRouter, 
    Login, 
    Home 
]) 
.config(['$stateProvider','$urlRouterProvider','$locationProvider'],routesConfig) 

.component('app', AppComponent); 
相關問題