【发布时间】:2018-06-17 05:49:01
【问题描述】:
var headerView = {
templateUrl: 'views/header/header.html',
controller: 'HeaderCtrl'
};
var footerView = {
templateUrl: 'views/footer/footer.html'
};
var myApp = angular.module('myApp', ['ui.router']);
myApp.controller('MainCtrl', function($scope) {});
myApp.config(function($stateProvider, $urlRouterProvider) {
// default route
$urlRouterProvider.otherwise("/");
// ui router states
$stateProvider
.state('first', {
url: "/first",
views: {
header: headerView,
content: {
template: '<p>First content</>',
controller: function($scope) {}
},
footer: footerView
}
})
.state('second', {
url: "/second",
views: {
header: headerView,
content: {
template: '<p>Second content</>',
controller: function($scope) {}
},
footer: footerView
}
});
});
在上面的代码中重复包含页眉和页脚,所以我想避免重复包含页眉和页脚。如何避免重复包含或抽象此页眉和页脚,我正在使用节点、web-pack、ui-router ..
【问题讨论】:
标签: angularjs node.js webpack routing angular-ui-router