0

I have some objects, each one has a property which shows their type, something like this:

[
    {
        "type" : "date",
        ...
    },{
        "type" : "phone",
        ...
    },{
        "type" : "boolean",
        ...
    }
]

I want to have something which shows them in their proper templates, which may differ in DOM,(for example one just has a span, the other has a check box and an input text and so on). I want to do this in a generic manner. How can I do this? (I use angular, if it helps)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Saeed
  • 7,262
  • 14
  • 43
  • 63

1 Answers1

0

I would create a directive that takes an object as a scoped variable and renders it as needed in the linked function.

<mydirective data='{ "type" : "date"}'>
Nikos
  • 7,295
  • 7
  • 52
  • 88