文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
参数定义
9.2. 参数定义
在作路由定义时,可以匹配一个规则,规则中可以定义路径中的某些部分作为参数之用,然后使用 `$routeParams` 服务获取到指定参数。比如 /#/book/test 中, `test` 作为参数传入到 controller 中:
<div ng-view></div>
<script type="text/javascript">
angular.module('ngView', [],
function($routeProvider){
$routeProvider.when('/book/:title',
{
template: '{ { title } }',
controller: function($scope, $routeParams){
$scope.title = $routeParams.title;
}
}
);
}
);
</script>
访问: /#/book/test
不需要预定义模式,也可以像普通 GET 请求那样获取到相关参数:
angular.module('ngView', [],
function($routeProvider){
$routeProvider.when('/book',
{
template: '{ { title } }',
controller: function($scope, $routeParams){
$scope.title = $routeParams.title;
}
}
);
}
);
访问: /#/book?title=test
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论