我有我的index.html页面,其中实现了ng-view。这同样适用于侧边栏,侧边栏也链接到3页(main.html,product.html和customer.html)。
我需要更改sidebar.html的类,例如当我在customer.html页面中时。
我试过从customerController做到但是没有结果。据我了解,因为sidebar.html由MyController控制 谁能指导我? 谢谢
以下是代码的相关部分:
的index.html
<html ng-app="appDataBoard">
<body ng-controller="MyController" >
<!-- SIDEBAR-->
<div ng-include="'./template/sidebar.html'" ></div>
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<div class="col-md-12 column sortable">
<div ng-view></div>
</div>
</div>
</body>
</html>
sidebar.html
<div class="page-sidebar-wrapper">
<ul >
<li class="nav-item start open">
<a href="#/main" class="nav-link nav-toggle"> </a>
</li>
<li class="nav-item ">
<a href="#/product" class="nav-link nav-toggle"></a>
</li>
<li ng-class="nav-item">
<a href="#/customer" class="nav-link nav-toggle"></a>
</li>
</ul>
</div>
<!-- END SIDEBAR -->
routing.js
var dbApp = angular.module('appDataBoard', ['ngRoute','ngMaterial', 'ngMessages', 'material.svgAssetsCache']);
// configure our routes
dbApp.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/main', {
templateUrl : 'template/main.html',
controller : 'mainController'
})
// route for the about page
.when('/product', {
templateUrl : 'template/product.html',
controller : 'productController'
})
// route for the contact page
.when('/customer', {
templateUrl : 'template/customer.html',
controller : 'customerController'
});
});