ng-model を使用してオプションを呼び出す選択があります。それは完全に機能しますが、モデルオプションの入力を使用して配列からオプションのリストを編集しようとしていますが、機能しません。
簡単に言えば、入力はオプションをコンマ区切りの値として表示しますが、リストを編集すると、選択が壊れます。このPlunkerで私が何を意味するかがわかります。
js は次のようになります。
var Select = function($scope) {
$scope.options =
[
"I live here!",
"By Boat",
"By Car",
"By Plane",
"By Bike",
"By Bus",
"Hitchhiking",
"Other"
];
$scope.form = {type : $scope.options[0]};
};
そしてhtml:
<form class="col-md-12" ng-controller="Select">
<select class="form-control" ng-model="form.type" ng-options="opt for opt in options">
</select>
<textarea ng-model="options" class="form-control"></textarea>
</form>
私は何が欠けていますか?