2017-09-03 61 views
1

所以我在我的我的樣式中聲明我的index.html。但是當我將它移動到一個單獨的文件並試圖在我的routeProvider中聲明樣式表時,它只是在頂部顯示了一個帶有導航欄的白頁(這是在main.css中的樣式)。我的routeProvider提供程序看起來像。角度路線提供樣式表

.when('/', { 
    templateUrl: 'static/partials/landing.html', 
    controller: IndexController 
    css: 'static/css/home.css' 
}) 
.when('/about', { 
    templateUrl: 'static/partials/about.html', 
    controller: AboutController 
}) 
.when('/post', { 
    templateUrl: 'static/partials/post-list.html', 
    controller: PostListController 
}) 
.when('/post/:postId', { 
    templateUrl: '/static/partials/post-detail.html', 
    controller: PostDetailController 
}) 
/* Create a "/blog" route that takes the user to the same place as "/post" */ 
.when('/blog', { 
    templateUrl: 'static/partials/post-list.html', 
    controller: PostListController 
}) 
.otherwise({ 
    redirectTo: '/' 
}); 

這是我第一次真正玩角度,所以我想我可能會錯過簡單的東西。我在網上搜索了一段時間,但沒有提到太多。

+0

你有沒有檢查[this](https://stackoverflow.com/questions/15193492/how-to-include-view-partial-specific-styling-in-angularjs)問題在這裏? –

回答

1

你不能只包括在routerProvider CSS沒有圖書館或指令進行編譯,或者你可以使用angular-css

var myApp = angular.module('myApp', ['ngRoute', 'angularCSS']); 

,然後提供配置個人CSS。

+0

這有幫助。感謝您的鏈接。 –