ngRoute.$routeParams

Improve this Doc View Source $routeParams

  1. service in module ngRoute

The $routeParams service allows you to retrieve the current set of route parameters.

Requires the ngRoute module to be installed.

The route parameters are a combination of $location's search() and path(). The path parameters are extracted when the $route path is matched.

In case of parameter name collision, path params take precedence over search params.

The service guarantees that the identity of the $routeParams object will remain unchanged (but its properties will likely change) even when a route change occurs.

Note that the $routeParams are only updated after a route change completes successfully. This means that you cannot rely on $routeParams being correct in route resolve functions. Instead you can use $route.current.params to access the new route's parameters.

Dependencies

// Given:
// URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
// Route: /Chapter/:chapterId/Section/:sectionId
//
// Then
$routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'}

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.6.4/docs/api/ngRoute/service/$routeParams

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部