2016-11-18 5 views
0

年の各月の内容を持つIonicアプリケーションを構築しています。ユーザーがアプリを起動したときの今月の内容を表示したいと思います。その後、ユーザーは(サイドメニューを介して)他の月のコンテンツを選択することができます。Ionic - 動的起動ページでstateParamsが取得されない

私は次のように$ ionicPlatform.readyでこれを行うために管理:

.run(function($ionicPlatform, $filter, $location, $rootScope, $state) { 
    $ionicPlatform.ready(function() { 
     // 
     // removed other code here for clarity 
     // 
     date = new Date(); 
     month = $filter('date')(date, 'M'); 
     newPath = '/maand/' + month + '/groenten'; 
     $location.path(newPath); 
     $rootScope.$apply(); 
    }); 
}) 

これは正しいビューに私を取るが、これはする必要があるURLから月のパラメータを取得できません。ヘッダーに動的タイトルを表示します。誰か助けてもらえますか?ありがとう!

答えて

0

パラメータを渡す状態を変更するには、$ stateProviderを使用する必要があります。 例:

.config(function($stateProvider, $urlRouterProvider) { 
     $stateProvider 
      .state('your-state', { 
       url: '/your-url', 
       params: {month: ""}, 
       templateUrl: 'templates/your-template.html', 
       controller: 'YourController' 
      }) 

ベターhereを説明しました。

関連する問題