回答編集履歴
2
a
test
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
// 選択状態解除
|
52
52
|
|
53
|
-
$scope.c
|
53
|
+
$scope.clearLocation = function(){
|
54
54
|
|
55
55
|
$scope.location = '';
|
56
56
|
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
</select>
|
82
82
|
|
83
|
-
<button ng-click="c
|
83
|
+
<button ng-click="clearLocation()">未選択</button>
|
84
84
|
|
85
85
|
</div>
|
86
86
|
|
1
a
test
CHANGED
@@ -11,3 +11,81 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
[リンク](http://plnkr.co/edit/8GhnFmxNRvtJCGOyLUKg?p=preview)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
上記リンク先を以下に変更しました。
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```html
|
22
|
+
|
23
|
+
<html>
|
24
|
+
|
25
|
+
<head>
|
26
|
+
|
27
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
<script>
|
32
|
+
|
33
|
+
angular.module('App', []).controller('formController', ['$scope', function($scope) {
|
34
|
+
|
35
|
+
// 初期値はブランク
|
36
|
+
|
37
|
+
$scope.location = '';
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
// bindは条件で分岐
|
42
|
+
|
43
|
+
$scope.selectedLocation = function(){
|
44
|
+
|
45
|
+
return $scope.location === '' ? '旅行地を選択' : $scope.location;
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
// 選択状態解除
|
52
|
+
|
53
|
+
$scope.crearLocation = function(){
|
54
|
+
|
55
|
+
$scope.location = '';
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
}]);
|
62
|
+
|
63
|
+
</script>
|
64
|
+
|
65
|
+
</head>
|
66
|
+
|
67
|
+
<body ng-app="App">
|
68
|
+
|
69
|
+
<div ng-controller="formController">
|
70
|
+
|
71
|
+
<div class="sel1" ng-bind="selectedLocation()"></div>
|
72
|
+
|
73
|
+
<select class="op1" multiple size="2" ng-model="location">
|
74
|
+
|
75
|
+
<option value="" disabled>旅行地を選択</option>
|
76
|
+
|
77
|
+
<option value="東京">東京</option>
|
78
|
+
|
79
|
+
<option value="その他関東地区">その他関東地区</option>
|
80
|
+
|
81
|
+
</select>
|
82
|
+
|
83
|
+
<button ng-click="crearLocation()">未選択</button>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</body>
|
88
|
+
|
89
|
+
</html>
|
90
|
+
|
91
|
+
```
|