2016-06-30 7 views
0

矢印をクリックして同じ状態に変更するページを取得しようとしていますが、新しいオブジェクトを表す新しいオブジェクト項目に更新しようとしていますビューでスライドします。角度 - URLがstate.goで更新されていますが、表示がレンダリングされていません

私のコードでは、私はURLを変更しますが、ビューは更新されません。

これは唯一の最初のスライドで発生するようですので、次の質問への矢印をクリックすると更新されませんでしたが、ページをリフレッシュしてクリックすると他の質問。

もう1つの例として、2番目、3番目、または4番目のアイテムをクリックしてスライダーに移動し、次に最初から移動しない限り、そこから次のアイテムをクリックしてください次のオブジェクトアイテムにスルーします。

// Index of the current item in the items array 
    scope.itemIndex = assessment.test.items.indexOf(item._id); 
    scope.numberOfItems = assessment.test.items.length; 

// Checks if the index is not equal to the length of items 
    if (scope.itemIndex !== scope.numberOfItems) { 
     var nextItemId = assessment.test.items[scope.itemIndex + 1]; 
    } 

// Checks if the index of the item is not greater than zero 
    if (scope.itemIndex > 0) { 
     var previousItemId = assessment.test.items[scope.itemIndex - 1]; 
    } 

/** 
* Go to the next question 
*/ 
    scope.next = function() { 
     state.go('app.main.3Col.results.details', { itemId: nextItemId, assessmentId: assessment._id }, { refresh: true }); 
    }; 

/** 
* Go to the previous question 
*/ 
    scope.previous = function() { 
     state.go('app.main.3Col.results.details', { itemId: previousItemId, assessmentId: assessment._id }, { refresh: true }); 
    }; 
+0

状態設定で 'reloadOnSearch'を設定しましたか? Trueがデフォルトですが、同じ状態にナビゲートするときにリロードを停止するので、falseに設定されていないことを確認してください。 – Duncan

答えて

0

オプションを使用しようと、私はとしてのparamとしてを通じてアイテムを渡すために必要な..私が悪かったのかを見る...

scope.next = function() { 
    state.go('app.main.3Col.results.details', { 
    itemId: nextItemId, 
    assessmentId: assessment._id 
    }, { 
    reload: true 
    }); 
}; 

https://github.com/angular-ui/ui-router/wiki/Quick-Reference#stategoto--toparams--options

+0

リロードを強制することは、他のアイデアは何もしていないようですか? – MaxwellLynn

+1

あなたのapp.js(ルートを定義する方法)とルート 'app.main.3Col.results.details'に割り当てるコントローラを教えてください – mtamma

0

[OK]を..私の悪いリロードそれは次の項目に更新されませんでした。コメントされている以下の変更を行うと、私の問題は解決しました。

 // Checks if the index is not equal to the length of items 
    if (scope.itemIndex !== scope.numberOfItems) { 
     var nextItemId = assessment.test.items[scope.itemIndex + 1]; 
     var nextItem = assessmentItems[scope.itemIndex + 1]; 
    } 

    // Checks if the index of the item is not greater than zero 
    if (scope.itemIndex > 0) { 
     var previousItemId = assessment.test.items[scope.itemIndex - 1]; 
     // I had to define the previous item and push it through 
     var previousItem = assessmentItems[scope.itemIndex - 1]; 
    } 

    /** 
    * Go to the next question 
    */ 
    scope.next = function() { 
     state.go('app.main.3Col.results.details', { item: nextItem, itemId: nextItemId }); 
    }; 
関連する問題