dimanche 13 novembre 2016

Angular 2 - Displaying checkboxes using key-value pairs

I'm caught up in a rather weird scenario.

My backend data looks like this,

"channelName": [
      "Online",
      "Offline"
    ],
    "paramList": [
      {
        "paramValue": [
          "First",
          "Second",
          "Third"
        ],
        "paramName": "Tier"
      },
      {
        "paramValue": [
          "First",
          "Second",
          "Third"
        ],
        "paramName": "Class"
      }
    ],

I have to display the channels, the tiers and the classes as checkboxes - but, please note that the params - class and tier or dynamic - which means that these names might change in the future. Channel, however is a field and won't change.

My Questions:

  1. Is it possible to map these dynamically to a model?
  2. Is it possible to implement a 'Select All' feature where if everything is selected, the 'Select All' checkbox is selected and the model is updated as ALL and not with the individual field names and vice-versa.

P.S: I am trying not to implement the solution where we add another variable in channel as channel name and selected channel : {channelName, selected}.




Aucun commentaire:

Enregistrer un commentaire