1

I have a Angular.js Web UI for editing complex and large mathematical objects. I'm trying to build a view that displays results for such an object. Thus, the edited object needs to be sent to the back-end and the back-end would compute a partial view based on its data.

The ordinary (easy) way of doing so would be to use the ngInclude directive:

<div ng-include=".../resultView?data=[JSON_stringyfied_object_here]>

This works. However the problem is that the object can be quite big in terms of numbers of chars used in a JSON representation (as they contain a lot of floating point number and dates etc.). So, I'm afraid of running into practical limitations of the length of a query string.

Instead, I'd rather send the object as payload of the GET (or even POST?) request. I'm just not sure how to accomplish this the Angular way. Is there a way of doing so?

Worst case, I can also live with a solution that displays a "Compute" button which would then fetch the partial view by calling a function that uses $http. How would I include this view in the DOM in this case?

I appreciate any hints in how people would tackle this problem.

EDIT: The view can look quite different depending on the (dynamic) type of the mathematical object and its computed results. Thus, rendering a static view and then filling data won't work.

Community
  • 1
  • 1
Dejan
  • 9,150
  • 8
  • 69
  • 117
  • It sounds more like you want a directive (which could possibly contain more directives). In general, my experience has been that if you break everything into enough directives, you don't _need_ to dynamically generate templates for partial views ... – mgilson Oct 27 '15 at 16:25
  • Even if the template is static, the view is an Angular application, so it **is** dynamic. If you are still convinced that the template has to be created dynamically, then you might take a look at something like `ngRoute` - essentially different templates for different situations. An example of yours would be helpful. – a better oliver Oct 27 '15 at 18:48
  • The route used to request a results view is not dynamic. But the rendered HTML view can be quite different (and is not known at compile time as the back-end has a plugin architecture): sometimes there might be some fields rendered, sometimes a grid and a few comboboxes, etc. I don't think this is a case for `ngRoute`. – Dejan Oct 28 '15 at 13:21

1 Answers1

0

What I would do is use ng-include to include a static templated page and then make a $http.put call to fetch the data and have it populate onto the templated page.

Eric
  • 6,563
  • 5
  • 42
  • 66
  • You mean the rendered partial would have an own controller which would then call `$http.put`? The problem is that the view is not static. Dependent on the results it can look completely different. – Dejan Oct 27 '15 at 16:29
  • @Dejan How often does the [tag:html] markup in the view change? – Eric Oct 30 '15 at 16:44
  • not sure about your question. The view is static per result type. So dependent on what the user has clicked, edited and configured, and dependent on which math. object he's looking at, pressing "Calculate" would give him/her the same view. – Dejan Oct 30 '15 at 16:49