使用HTML5 pushstate在angular.js上使用。
使用HTML5 pushstate在angular.js上使用。
我正在尝试使用HTML5的pushstate来代替Angularjs中使用的#导航。我已经尝试通过谷歌搜索和Angular IRC聊天室寻找答案,但目前还没有成功。
这是我的controllers.js文件:
function PhoneListCtrl($scope, $http) { $http.get('phones/phones.json').success(function(data) { $scope.phones = data; }); } function PhoneDetailCtrl($scope, $routeParams) { $scope.phoneId = $routeParams.phoneId; } function greetCntr($scope, $window) { $scope.greet = function() { $("#modal").slideDown(); } }
app.js文件:
angular.module('phoneapp', []). config(['$routeProvider', function($routeProvider){ $routeProvider. when('/phones', { templateUrl: 'partials/phone-list.html', controller: PhoneListCtrl }). when('/phones/:phoneId', { templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl }). otherwise({ redirectTo: '/phones' }); }]);