// 带#号的url,看?号的url,见下面 url = http://qiaole.sinaapp.com?#name=cccccc $location.absUrl(); // http://qiaole.sinaapp.com?#name=cccccc $location.host(); // qiaole.sinaapp.com $location.port(); // 80 $location.protocol(); // http $location.url(); // ?#name=cccccc // 获取url参数 $location.search().name; // or $location.search()['name']; // 注:如果是这样的地址:http://qiaole.sinaapp.com?name=cccccc var searchApp = angular.module('searchApp', []); searchApp.config(['$locationProvider', function($locationProvider) { $locationProvider.html5Mode(true); }]); searchApp.controller('MainCtrl', ['$scope', '$location', function($scope, $location) { if ($location.search().keyword) { $scope.keyword = $location.search().keyword; } }]);