如何从以下 URL 获取 ng-controller
中 access_token
的值作为 $routeParams
?
http://www.example.com/#/access_token=asdfjaksjdhflanblasdfkjahdloahds
最佳答案
在您的应用程序配置上
App.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/:id', {
....
controller: 'DetailsController'
}).
在 Controller 上使用$routeParams
.controller("DetailsController", ['$routeParams',function($routeParams){
var id = $routeParams.id; // this name is from config :id
}]);
关于javascript - 从 Angular.js 中的 URL 获取路由参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26100931/