안녕하세요. 그래서 routeProvider 및 ng-view를 사용하여 Angularjs의보기간에 라우팅합니다. 내 문제는 경로가 변경되면 내 CSS가로드되지 않는다는 것입니다. CSS를 각보기에 포함시킬 수 있도록 Angular-css를 포함 시키려고했지만 작동하지 않는 것 같습니다. ng-view (home.html)에서로드 된 첫 번째 페이지에로드되지만 다른 페이지로 링크하면 CSS로드가 중지됩니다.angularjs에서 라우팅 할 때 CSS가 다른보기에로드되지 않습니다.
index.html을 :
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<script src="app/lib/jquery-3.0.0.js"></script>
<link href="styles.css" rel="stylesheet" type="text/css" />
<script src="app/lib/angular.min.js"></script>
<script src="app/lib/angular-route.min.js"></script>
<script src="app/lib/angular-css.min.js"></script>
<script src="app/lib/app.js"></script>
</head>
<body>
<main ng-view>
</main>
</body>
이
var myApp = angular.module('myApp', ['ngRoute', 'angularCSS']);
myApp.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/login', {
templateUrl: 'views/login.html',
css: 'styles.css'
})
.when('/home', {
templateUrl: 'views/home.html',
css: 'styles.css'
})
.when('/signup', {
templateUrl: 'views/signup.html',
css: 'styles.css'
})
.when('/submitdish', {
templateUrl: 'views/submitdish.html',
css: 'styles.css'
})
.when('/login', {
templateUrl: 'views/login.html',
css: 'styles.css'
})
.otherwise({
redirectTo: '/home',
css: 'styles.css'
});
}]);
home.html을 app.js : 변화하는
<ul class="nav">
<a align="center" href="views/home.html"><li>Home</li></a>
<a align="center" href=""><li>About</li></a>
<a align="center" href="#"><li>Contact</li></a>
</ul>
<section class="container">
<div class="left-half">
<article>
<a href="views/submitdish.html" class="Button">Sell a Dish</a>
<p>Something Something Something about Selling your home-cooked dishes</p>
</article>
</div>
<div class="right-half">
<article>
<a href="views/buydish.html" class="Button">Buy a Dish</a>
<p>Yada yada yada buy food from your neighbors</p>
</article>
</div>
</section>
이 문제를 재현하고 그것을 피들에 게시 할 수 있습니까? –