質問編集履歴
1
遷移先htmlと遷移先jsの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
### 該当のソースコード
|
8
8
|
|
9
9
|
```html
|
10
|
+
**index.html**
|
11
|
+
|
10
12
|
<!DOCTYPE HTML>
|
11
13
|
<html ng-app="myApp">
|
12
14
|
|
@@ -18,7 +20,7 @@
|
|
18
20
|
<label><input type="checkbox" ng-model="fruit.checked">{{fruit.name}}</label>
|
19
21
|
</li>
|
20
22
|
</ul>
|
21
|
-
<a href="
|
23
|
+
<a href="test.html" ng-click="check()">
|
22
24
|
完了
|
23
25
|
</a>
|
24
26
|
<p ng-repeat="data in foods">{{data}}</p>
|
@@ -28,9 +30,31 @@
|
|
28
30
|
</html>
|
29
31
|
```
|
30
32
|
|
33
|
+
```html
|
34
|
+
**test.html**
|
35
|
+
|
36
|
+
<!DOCTYPE HTML>
|
37
|
+
<html ng-app="myApp">
|
38
|
+
|
39
|
+
<省略>
|
40
|
+
|
41
|
+
<div ng-controller="NewAppController">
|
42
|
+
|
43
|
+
<p ng-repeat="data in testVar">{{data}}</p>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
</body>
|
47
|
+
</html>
|
48
|
+
```
|
49
|
+
|
31
50
|
```js
|
51
|
+
|
52
|
+
var testVar = [];
|
53
|
+
|
32
|
-
angular.module('myApp', [])
|
54
|
+
var app = angular.module('myApp', []);
|
55
|
+
|
56
|
+
//遷移元コントローラー
|
33
|
-
|
57
|
+
app.controller('AppController', function($scope) {
|
34
58
|
$scope.fruits = [
|
35
59
|
{id: 1, name: 'リンゴ'},
|
36
60
|
{id: 2, name: 'バナナ'},
|
@@ -40,16 +64,21 @@
|
|
40
64
|
];
|
41
65
|
|
42
66
|
$scope.check = function() {
|
43
|
-
|
67
|
+
|
44
68
|
angular.forEach($scope.fruits, function(value, index, array) {
|
45
69
|
if (value.checked) {
|
46
|
-
|
70
|
+
testVar.push(value.name);
|
47
71
|
console.log(value.name);
|
48
72
|
}
|
49
|
-
$scope.
|
73
|
+
$scope.testVar = testVar;
|
50
74
|
});
|
51
|
-
}
|
75
|
+
};
|
52
|
-
}
|
76
|
+
};
|
77
|
+
|
78
|
+
//遷移先コントローラー
|
79
|
+
app.controller('NewAppController', function($scope) {
|
80
|
+
$scope.testVar;
|
81
|
+
});
|
53
82
|
```
|
54
83
|
### 試したこと
|
55
84
|
|