ui-select の選択ボックスを使用しています。すべて正常に動作していますが、手動で入力したテキストを許可し、リストで使用可能な値からユーザーを制限したくありません。テキストを入力すると、リストが正しくフィルタリングされます。しかし、要素をクリックせずに次のフィールドに移動すると、テキストが破棄されます。
何か案は?
よろしくお願いします、アレックス
コードが正しくないと思うので表示したくなかったのですが、次のように要求されました。
<ui-select ng-model="formData[field.id].selected" theme="bootstrap">
<ui-select-match placeholder="{{ lists[field.id].placeholder }}">{{$select.selected.text}}</ui-select-match>
<ui-select-choices repeat="item in lists[field.id].list | filter: $select.search">
<div ng-bind-html="item.text | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
データは に保存されformData[field.id].selected
ます。field.id
表示する現在のフィールドの番号です(フォームを動的に生成しています)。一意の int 値が格納されていると仮定してください。
編集 08.04.2015 私の解決策: C# コンボボックスに相当するものがないように見えることがわかりました。そこで私は先に進み、2 つの別々のフィールドを使用しました。それは私が望んでいたものではありませんが、今のところ機能します:
<ui-select ng-model="formData[field.id].selected" theme="bootstrap">
<ui-select-match placeholder="{{ lists[field.id].placeholder }}">{{$select.selected.text}}</ui-select-match>
<ui-select-choices repeat="item in lists[field.id].list | filter: $select.search">
<div ng-bind-html="item.text | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
<?php echo __('Create a new element if value is not in list'); ?>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" ng-model="disabled[field.id]">
</span>
<input type="text" value="" ng-disabled="!disabled[field.id]" class="form-control" ng-model="formData[field.id].newValue" />
</div>