質問編集履歴

1

遷移先htmlと遷移先jsの追加

2018/05/18 01:59

投稿

sato1108
sato1108

スコア14

test CHANGED
File without changes
test CHANGED
@@ -15,6 +15,10 @@
15
15
 
16
16
 
17
17
  ```html
18
+
19
+ **index.html**
20
+
21
+
18
22
 
19
23
  <!DOCTYPE HTML>
20
24
 
@@ -38,7 +42,7 @@
38
42
 
39
43
  </ul>
40
44
 
41
- <a href="*******" id="submitLabel" ng-click="check()">
45
+ <a href="test.html" ng-click="check()">
42
46
 
43
47
  完了
44
48
 
@@ -58,11 +62,55 @@
58
62
 
59
63
 
60
64
 
65
+ ```html
66
+
67
+ **test.html**
68
+
69
+
70
+
71
+ <!DOCTYPE HTML>
72
+
73
+ <html ng-app="myApp">
74
+
75
+
76
+
77
+ <省略>
78
+
79
+
80
+
81
+ <div ng-controller="NewAppController">
82
+
83
+
84
+
85
+ <p ng-repeat="data in testVar">{{data}}</p>
86
+
87
+
88
+
89
+ </div>
90
+
91
+ </body>
92
+
93
+ </html>
94
+
95
+ ```
96
+
97
+
98
+
61
99
  ```js
62
100
 
63
- angular.module('myApp', [])
64
101
 
102
+
103
+ var testVar = [];
104
+
105
+
106
+
107
+ var app = angular.module('myApp', []);
108
+
109
+
110
+
111
+ //遷移元コントローラー
112
+
65
-   .controller('AppController', function($scope) {
113
+ app.controller('AppController', function($scope) {
66
114
 
67
115
  $scope.fruits = [
68
116
 
@@ -82,25 +130,35 @@
82
130
 
83
131
  $scope.check = function() {
84
132
 
85
- var food = [];
133
+
86
134
 
87
135
  angular.forEach($scope.fruits, function(value, index, array) {
88
136
 
89
137
  if (value.checked) {
90
138
 
91
- food.push(value.name);
139
+ testVar.push(value.name);
92
140
 
93
141
  console.log(value.name);
94
142
 
95
143
  }
96
144
 
97
- $scope.foods = food;
145
+ $scope.testVar = testVar;
98
146
 
99
147
  });
100
148
 
101
- }
149
+ };
102
150
 
103
- }
151
+ };
152
+
153
+
154
+
155
+ //遷移先コントローラー
156
+
157
+ app.controller('NewAppController', function($scope) {
158
+
159
+ $scope.testVar;
160
+
161
+ });
104
162
 
105
163
  ```
106
164