خرید بک لینک

Vote count: 0

In my AngularJS application, I have a standard CRUD component that manages most of the systems entities. This component (which is a directive) is basically a table that receives its columns metadata (JSON) and do its magic. The thing is, each entity has its own columns, and I want to load them with a simple call to a service like MyService.getColumns(entity). I could do a huge switch statement (like shown above), but I don't want that because any user that log in the system would have the load the metadata for all the entities available in the system, maybe to manage only one.

A (not desired) solution to my situation:

switch(entity.name) {
    case 'FOO':
        retu [column1JSON, column2JSON, ...];
    case 'FOO2':
        retu [column2JSON, column3JSON, ...];
    ...
}

Still, some columns definitions are shared among entities, so it would be great to have a solution where I can "extend" the retued columns or reuse a group of columns somehow.

Basically, I would like to know what's the best way (using AngularJS) to implement this service and even if it should be a service at all. Thanks.

asked 26 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 15 مرداد 1395 ساعت: 21:40

صفحه بندی