Batman
Batman

Reputation: 6353

Advice on structuring and rendering different objects within the same view

I'm building an application and I'm looking for some advice on how to structure a specific piece of functionality I'm working on.

I have this reports view, on this page a drop down with various reports a user can generate. This is what it looks like:

enter image description here

enter image description here

The drop down is just an array I hard coded in the controller. When a user selects a specific report, the controller makes a call to the ReportFactory and returns the selected report object, from there the view builds the report using the returned object.

However, this doesn't work with multiple reports since the html table is completely different depending on the report I need and as of now I've hard coded the report table into the view.

What would be the best way to switch between different reports which would each have their own function to build the object, their own html to render the table and where I can still implement DataTables to all of them once I get to that step.

Upvotes: 0

Views: 54

Answers (1)

ragefuljoe
ragefuljoe

Reputation: 246

You could possibly use a named ui-view with ui-router, then each dropdown would be a state which can load a different templateURL and controller.

Upvotes: 2

Related Questions