質問編集履歴
6
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
<ons-list ng-controller="PageControler as PgCtrl">
|
48
48
|
|
49
|
-
<ons-list-item ng-repeat="item in PgCtrl.items
|
49
|
+
<ons-list-item ng-repeat="item in PgCtrl.items">
|
50
50
|
|
51
51
|
<label style="color: #ff4500">{{item.word}}</label>
|
52
52
|
|
@@ -68,9 +68,35 @@
|
|
68
68
|
|
69
69
|
var app = angular.module('myApp',["onsen"]);
|
70
70
|
|
71
|
-
app.controller('PageController', function() {
|
71
|
+
app.controller('PageController',['shuffle','data', function(shuffle, data) {
|
72
72
|
|
73
|
-
this.items =
|
73
|
+
this.items = shuffle(data);
|
74
|
+
|
75
|
+
};
|
76
|
+
|
77
|
+
app.value('shuffle', function(array) {
|
78
|
+
|
79
|
+
var n = array.length;
|
80
|
+
|
81
|
+
while(n) {
|
82
|
+
|
83
|
+
i = Math.floor(Math.random()*n--);
|
84
|
+
|
85
|
+
t = array[n];
|
86
|
+
|
87
|
+
array[n] = array[i];
|
88
|
+
|
89
|
+
array[i] = t;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
return array;
|
94
|
+
|
95
|
+
});
|
96
|
+
|
97
|
+
app.value('data',
|
98
|
+
|
99
|
+
[
|
74
100
|
|
75
101
|
{ word: "hoga",mean: "hoga" },
|
76
102
|
|
@@ -78,17 +104,7 @@
|
|
78
104
|
|
79
105
|
{ word: "hogo",mean: "hogo" }
|
80
106
|
|
81
|
-
];
|
107
|
+
]);
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
this.mySort = function(item) {
|
86
|
-
|
87
|
-
return Math.random();
|
88
|
-
|
89
|
-
};
|
90
|
-
|
91
|
-
};
|
92
108
|
|
93
109
|
```
|
94
110
|
|
4
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
<ons-list ng-controller="PageControler as PgCtrl">
|
48
48
|
|
49
|
-
<ons-list-item ng-repeat="item in PgCtrl.items">
|
49
|
+
<ons-list-item ng-repeat="item in PgCtrl.items | orderBy: PgCtrl.mySort">
|
50
50
|
|
51
51
|
<label style="color: #ff4500">{{item.word}}</label>
|
52
52
|
|
@@ -80,7 +80,15 @@
|
|
80
80
|
|
81
81
|
];
|
82
82
|
|
83
|
+
|
84
|
+
|
85
|
+
this.mySort = function(item) {
|
86
|
+
|
87
|
+
return Math.random();
|
88
|
+
|
83
|
-
}
|
89
|
+
};
|
90
|
+
|
91
|
+
};
|
84
92
|
|
85
93
|
```
|
86
94
|
|
3
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,18 +5,6 @@
|
|
5
5
|
リスト要素一つ一つに対して行いたいので、classで一元的に管理するのは合わないかなと。
|
6
6
|
|
7
7
|
ご教授お願いします(._.)
|
8
|
-
|
9
|
-
###発生している問題・エラーメッセージ
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
```
|
14
|
-
|
15
|
-
エラーメッセージ
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
|
20
8
|
|
21
9
|
###該当のソースコード
|
22
10
|
|
@@ -50,7 +38,11 @@
|
|
50
38
|
|
51
39
|
<ons-page>
|
52
40
|
|
41
|
+
<ons-toolbar>
|
42
|
+
|
53
|
-
<ons-too
|
43
|
+
<ons-back-button>Pop</ons-back-button>
|
44
|
+
|
45
|
+
</ons-toolbar>
|
54
46
|
|
55
47
|
<ons-list ng-controller="PageControler as PgCtrl">
|
56
48
|
|
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,103 @@
|
|
1
|
+
###前提・実現したいこと
|
2
|
+
|
1
3
|
ng-repeatで生成したリストに対して、クリックイベントでテキストカラーが変更されるようにしたいです。
|
2
4
|
|
3
|
-
リスト一つ一つに対して行いたいので、classで一元的に管理するのは合わないかなと。
|
5
|
+
リスト要素一つ一つに対して行いたいので、classで一元的に管理するのは合わないかなと。
|
4
6
|
|
5
7
|
ご教授お願いします(._.)
|
8
|
+
|
9
|
+
###発生している問題・エラーメッセージ
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
エラーメッセージ
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
###該当のソースコード
|
22
|
+
|
23
|
+
```HTML5
|
24
|
+
|
25
|
+
<body>
|
26
|
+
|
27
|
+
<ons-navigator id="navi">
|
28
|
+
|
29
|
+
<ons-page>
|
30
|
+
|
31
|
+
<ons-toolbar></ons-toolbar>
|
32
|
+
|
33
|
+
<ons-list>
|
34
|
+
|
35
|
+
<ons-list-item modifier="chevron" onclick="navi.pushPage('page1.html')">
|
36
|
+
|
37
|
+
Push
|
38
|
+
|
39
|
+
</ons-list-item>
|
40
|
+
|
41
|
+
</ons-list>
|
42
|
+
|
43
|
+
</ons-page>
|
44
|
+
|
45
|
+
</ons-navigator>
|
46
|
+
|
47
|
+
<!-- page1.html -->
|
48
|
+
|
49
|
+
<ons-template id="page1.html">
|
50
|
+
|
51
|
+
<ons-page>
|
52
|
+
|
53
|
+
<ons-toolbar></ons-toolbar>
|
54
|
+
|
55
|
+
<ons-list ng-controller="PageControler as PgCtrl">
|
56
|
+
|
57
|
+
<ons-list-item ng-repeat="item in PgCtrl.items">
|
58
|
+
|
59
|
+
<label style="color: #ff4500">{{item.word}}</label>
|
60
|
+
|
61
|
+
<!-- 以下のlabelタグのテキストカラーを変えたい(灰色⇔白色) -->
|
62
|
+
|
63
|
+
<label class="right" style="color: ##808080">{{item.mean}}</label>
|
64
|
+
|
65
|
+
</ons-list-item>
|
66
|
+
|
67
|
+
</ons-list>
|
68
|
+
|
69
|
+
</ons-page>
|
70
|
+
|
71
|
+
</ons-template>
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
```AngularJS
|
76
|
+
|
77
|
+
var app = angular.module('myApp',["onsen"]);
|
78
|
+
|
79
|
+
app.controller('PageController', function() {
|
80
|
+
|
81
|
+
this.items = [
|
82
|
+
|
83
|
+
{ word: "hoga",mean: "hoga" },
|
84
|
+
|
85
|
+
{ word: "hoge",mean: "hoge" },
|
86
|
+
|
87
|
+
{ word: "hogo",mean: "hogo" }
|
88
|
+
|
89
|
+
];
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
###試したこと
|
96
|
+
|
97
|
+
課題に対してアプローチしたことを記載してください
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
###補足情報(言語/FW/ツール等のバージョンなど)
|
102
|
+
|
103
|
+
より詳細な情報
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
ng-repeatで生成したリストに対して、クリックイベントでテキストカラーが変更されるようにしたいです。
|
2
2
|
|
3
|
-
|
3
|
+
リスト一つ一つに対して行いたいので、classで一元的に管理するのは合わないかなと。
|
4
4
|
|
5
5
|
ご教授お願いします(._.)
|