【发布时间】:2015-04-25 13:59:54
【问题描述】:
我试图弄清楚如何在 angularjs 材料设计中的页面之间进行路由。
在此示例中,我想在单击侧边栏链接时更改页面 http://codepen.io/kyleledbetter/pen/gbQOaV
Script.js
// script.js
// create the module and name it scotchApp
// also include ngRoute for all our routing needs
var starterApp = angular.module('starterApp', ['ngRoute']);
// configure our routes
starterApp.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'pages/home.html',
controller : 'mainController'
})
// route for the about page
.when('/about', {
templateUrl : 'pages/about.html',
controller : 'aboutController'
})
// route for the contact page
.when('/contact', {
templateUrl : 'pages/contact.html',
controller : 'contactController'
});
});
// create the controller and inject Angular's $scope
starterApp.controller('mainController', function($scope) {
// create a message to display in our view
$scope.message = 'Everyone come and see how good I look!';
});
starterApp.controller('aboutController', function($scope) {
$scope.message = 'Look! I am an about page.';
});
starterApp.controller('contactController', function($scope) {
$scope.message = 'Contact us! JK. This is just a demo.';
});
about.html
<div class="jumbotron text-center">
<h1>About Page</h1>
<p>{{ message }}</p>
</div>
【问题讨论】:
-
能不能把你的html页面写成about.html等所有的
-
我没有完全理解你的问题,请详细解释
-
当您单击侧面菜单中的链接时,我正在尝试显示另一个页面。我之前在 angularJs 中使用 script.js 完成了此操作。现在我正在使用 angularJS 和材料设计,它不再工作了,我想知道我做错了什么。