我已经完全初始化了$stateProvider,并且我使用了所有这些状态和ui-sref。效果很好。用户按下按钮,然后将$stateProvider转到编辑页面。
在这个页面上,我有一个$http请求的表单:
this.pushData = function (data) {
$http.post('/data/' + $stateParams.dataId + '/otherdata', JSON.stringify({
id: otherdata.id,
name: otherdata.name
}), configAuth).then(
function success(response) {
var addedData = response.data;
$.notify({message: addedData.name + " has been added"},{type:'success'});
$state.go('roleInfo({roleId: $stateParams.roleId})');
},
function error(data) {
console.log(data);
$.notify({message: data.data.message},{type:'danger'});
}
);
}如果一切都好的话,我想重定向到其他观点。但这一点:
$state.go('roleInfo({roleId:$stateParams.roleId})');
不起作用。我如何使用params来做$state.go呢?
发布于 2016-06-17 11:05:20
您尝试使用ui-sref指令的方式,在使用$state.go方法调用它时,应该传递第一个参数stateName &然后以Object格式传递params。
$state.go('roleInfo', {roleId: $stateParams.roleId});发布于 2016-06-17 11:04:50
试试这个:
$state.go('myStateName', {roleId: $stateParams.roleId});
你可以在这里读到文档
发布于 2016-06-17 11:07:19
我已经把$state.go('roleInfo({roleId: $stateParams.roleId})');改为
$state.go('roleInfo',{roleId :$stateParams.roleId});这会起作用的
this.pushData = function (data) {
$http.post('/data/' + $stateParams.dataId + '/otherdata', JSON.stringify({
id: otherdata.id,
name: otherdata.name
}), configAuth).then(
function success(response) {
var addedData = response.data;
$.notify({message: addedData.name + " has been added"},{type:'success'});
$state.go('roleInfo',{roleId :$stateParams.roleId}); },
function error(data) {
console.log(data);
$.notify({message: data.data.message},{type:'danger'});
}
);
}https://stackoverflow.com/questions/37879925
复制相似问题