Angularjs 获取组件的ui路由器alpha中的state.params
我正在使用。我尝试在使用组件时检索参数,我尝试了旧的Angularjs 获取组件的ui路由器alpha中的state.params,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我正在使用。我尝试在使用组件时检索参数,我尝试了旧的$state.params和$stateparms,但这不起作用。我不能使用resolve,因为我们使用的是带有“ocLazyLoad”的动态路由。有什么建议吗 比如: $stateProvider .state('test', { url: "/test/:id", component: "myComponent" }); 有一个打字错误。例如:id不能被识别为参数。(/缺失) 有一个打字错误。例如:id不能被识别为参数
$state.params
和$stateparms
,但这不起作用。我不能使用resolve,因为我们使用的是带有“ocLazyLoad”的动态路由。有什么建议吗
比如:
$stateProvider
.state('test', {
url: "/test/:id",
component: "myComponent"
});
有一个打字错误。例如:id不能被识别为参数。(/缺失)
有一个打字错误。例如:id不能被识别为参数。(/缺失)
我不确定您是否在问这个问题,但可以像下面这样访问状态参数
.state('question',{
url : '/question/:id' // or url : '/question/{id}'
controller : 'SomeController',
component : 'someComponent'
});
并根据需要访问参数
.controller('SomeController',function($state,$stateParams){
$scope.id = $stateParams.id;
});
我不确定您是否在问这个问题,但可以像下面这样访问状态参数
.state('question',{
url : '/question/:id' // or url : '/question/{id}'
controller : 'SomeController',
component : 'someComponent'
});
并根据需要访问参数
.controller('SomeController',function($state,$stateParams){
$scope.id = $stateParams.id;
});
嗨,Ferox,打字错误只是我在这里发布的代码的一部分,在代码中是可以的。不过我在帖子里更正了。谢谢,打字错误只是我在这里发布的代码的一部分,在代码中是可以的。不过我在帖子里更正了。谢谢