私はAngularjsの学習を始めました。私はw3schoolsのチュートリアルに従っていたので、何かを試してみる必要がありました。ラジオボタンに従って選択を更新してください
ここでは、チェックしたラジオボタンに従ってドロップダウンリストを表示します。 (「名前」を選択すると、ドロップダウンリストに名前だけが必要です。都市を選択すると、「都市」ドロップダウンリストなどが必要です)。
<body ng-app="myApp" ng-controller="myController">
<div>
<input type="radio" ng-model="selection" value="Name">Name
<input type="radio" ng-model="selection" value="Country">Country
<input type="radio" ng-model="selection" value="City">City
<br>
<div ng-switch="selection">
<div ng-switch-when="Name">
<ul>
<li ng-repeat="x in names">{{x.Name}}</li>
</ul>
</div>
<div ng-switch-when="Country">
<ul>
<li ng-repeat="x in names">{{x.Country}}</li>
</ul>
</div>
<div ng-switch-when="City">
<ul>
<li ng-repeat="x in names">{{x.City}}</li>
</ul>
</div>
</div>
<br>
<select ng-model="selectedName" ng-options="x.Name for x in names"></select>
</div>
</body>
これは角度のあるスクリプトファイルです。
var app = angular.module('myApp',[]);
app.controller('myController', function($scope,$http){
$http.get('http://www.w3schools.com/angular/customers.php')
.then(function(response){
$scope.names = response.data.records;
});
});
ありがとう。これが私の必要なものです。 –