0
目的:$ scope .pluraliserは、年が選択されたときにランダムな値を返すようにします。 1966 現在、複数の値が同じ場合、常に最後の値が選択されます。フィッシャーイエーツシャッフル配列アルゴリズムAngularJS ng-pluralizerからランダムな値を取得する方法は?
を使用して
の$ scope.pluralizer = {
1966 : "Something New !",
1966 : "Something Different!",
1966 : "Something Else",
1967 : "Something New !",
1967 : "Something Different!"',
1967 : "Something Else",
1968 : "Something New !",
1968 : "Something Different!",
1968 : "Something Else"
}
You can randomise nested lists quite easily with ng-repeat
http://jsfiddle.net/owenmead/fa4v8/1/
$ scope.list = [
'"1966" : "Something New !"',
'"1966" : "Something Different!"',
'"1966" : "Something Else"',
'"1967" : "Something New !"',
'"1967" : "Something Different!"',
'"1967" : "Something Else"',
'"1968" : "Something New !"',
'"1969" : "Something Different!"',
'"1970" : "Something Else"',
]
$scope.random = function() {
return 0.5 - Math.random();
HTML
<p ng-repeat="i in list|orderBy:random">{{i}}</p>
とランダム化配列はどのように私はそうPluralizerをランダム化することができ年が選択されたときに異なる/ランダムな値を返しますか?