タグ

angularjsとcheckboxに関するlax34のブックマーク (2)

  • How do I bind to list of checkbox values with AngularJS?

    I have a few checkboxes: <input type='checkbox' value="apple" checked> <input type='checkbox' value="orange"> <input type='checkbox' value="pear" checked> <input type='checkbox' value="naartjie"> That I would like to bind to a list in my controller such that whenever a checkbox is changed the controller maintains a list of all the checked values, for example, ['apple', 'pear']. ng-model seems to o

    How do I bind to list of checkbox values with AngularJS?
  • angularjs_array_checkbox_binding

    プログラムの要件としては以下の通りです。 APIから上記のFruitsとUserを取得した結果に基づきビューを生成する。 User内のLikeFruitsはFruitsをマスタとしてチェックボックスを用いて更新する。 Userを受信した際にLikeFruitsに含まれていた値はチェック済みとする。 実装例 チェックボックスとのバインディング実装した例が以下になります。 Array Binding CheckBox 挙動としては以下のようになります。 チェック前 チェック後 チェックボックスと配列をバインディングする際に意識する点は二つあります。 一つはチェック状態をどのように評価するか。 もう一つはチェックのイベントでの挙動をどのようにするかです。 チェックの評価 今回の例ではチェックの評価は以下のように行っています。 <ul ng-repeat="(fruitId,fruitName)

    angularjs_array_checkbox_binding
  • 1