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
  • 32,421
  • 21
  • 173
  • 232
Saeed
  • 6,520
  • 12
  • 37
  • 61

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
  • 6,553
  • 6
  • 43
  • 76