您应该使用ngRoute。通过“ngRoute”的礼貌,您可以通过特定的URL将用户重定向到特定的视图。请对此进行一些研究。假设你解决了你的观点和重定向问题。你将如何从服务器端获取数据?这时我建议你看看服务和工厂对象。 希望它有帮助。
示例代码:
// create the module and name it exApp
// also include ngRoute for all our routing needs
var exApp= angular.module('exApp', ['ngRoute']);
// configure our routes
exApp.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
exApp.controller('mainController', function($scope) {
// create a message to display in our view
$scope.message = 'Everyone come and see how good I look!';
});
exApp.controller('aboutController', function($scope) {
$scope.message = 'Look! I am an about page.';
});
exApp.controller('contactController', function($scope) {
$scope.message = 'Contact us! JK. This is just a demo.';
});
https://github.com/angular-ui/ui-router – pegla