2016-05-04 1 views
0

私はMETEORを初めて使いました。流星と角を使ってアプリケーションを作成しました。しかし、私はリダイレクションのものに苦しんでいます。エントリを作成した後、リストページにリダイレクトしたいエントリーを作成した後、流星群アプリケーションでui-stateを変更します。

はコードの下に見つける:

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

$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'); 
    } 
} 
+0

..エラー:$状態はあなたがコントローラに$状態を注入なかった – user1787700

+0

が定義されていませんか?チェックコンストラクタ($ stateParams、$ state、$ scope、$ reactive、$ location)行 – shershen

+0

はい、注入しました。コンストラクタ($ stateParams、$ state、$ scope、$ reactive、$ location) – user1787700

0

好きコントローラはなります。働いていない

class ProsperFilterAdd { 
    constructor($scope, $reactive, $state) { 
     'ngInject'; 

     this.$state = $state; 

     $reactive(this).attach($scope); 

    } 
    save(){ 
     this.$state.go('prosper_filter_create'); 
    } 
} 
関連する問題