0

I want to use a dropdown button instead of a select-options in a form. I'm using angular, and the problem is: 1. The dropdown should display the name of the selection but the form should submit its Id instead 2. Changes to the dropdown don't make the form dirty

How do I resolve this?

4

1 に答える 1

0

OK、解決しました。ドロップダウン ボタンの ng-if 式に非常に小さな typeo があったようです。これにより、リストから選択した項目ではなく、常に「なし」と表示されていました。これにより、フォームでの選択がモデルに反映されていないと考えるようになりました..

とにかく、ここに私の作業コードペンがあります - 私はフォーム フィールド コントローラーのsetViewModelを使用して、ドロップダウンから非表示の入力フィールドに値をプッシュしています。

form.groupId.$setViewValue(group.id);

とにかく、これを行うのが最もエレガントな方法のようです(私が見つけることができた)(ディレクティブを使用して選択入力を完全に置き換えることを除いて..)

お役に立てれば!

于 2015-11-29T13:27:09.643 に答える