我是METEOR的新手。我使用流星和角度创建了一个应用程序。但我正在努力改变方向。我想在创建条目后重定向到列表页面。
找到以下代码:
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
class ProsperFilterAdd {
constructor($stateParams, $scope, $reactive, $location) {
'ngInject';
$reactive(this).attach($scope);
}
save(){
this.call('filters.insert', this.formData);
// TODO: NEED TO REDIRECT AT LIST PAGE OF FILTERS
}
}
export default angular.module(name, [
angularMeteor,
uiRouter
]).component(name, {
templateUrl: `imports/ui/components/${name}/${name}.html`,
controllerAs: name,
controller: ProsperFilterAdd
})
.config(config);
function config($stateProvider) {
'ngInject';
$stateProvider
.state('prosper_filter_create', {
url: '/prosper_filters/create',
template: '<prosper-filter-add></prosper-filter-add>'
});
}
请指导我,我在哪里做错了。
答案 0 :(得分:0)
使用$state.go(STATE_NAME)
代码。你的控制器看起来像
class ProsperFilterAdd {
constructor($stateParams, $state, $scope, $reactive, $location) {
'ngInject';
$reactive(this).attach($scope);
} //removed ); here
save(){
this.call('filters.insert', this.formData);
// TODO: NEED TO REDIRECT AT LIST PAGE OF FILTERS
$state.go('prosper_filter_create');
}
}
答案 1 :(得分:0)
我认为这是正确的方法。
class ProsperFilterAdd {
constructor($scope, $reactive, $state) {
'ngInject';
this.$state = $state;
$reactive(this).attach($scope);
}
save(){
this.$state.go('prosper_filter_create');
}
}