Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am integrating new angular functionality into an older application. The pattern in the older application is one where the server loads data and renders it to the dom as part of the request. This is kind of opposite to the pattern that Angular lends towards, where the server renders a minimal, light page and then the data is typically loaded via an ajax call using an angular service.

I don't want to mix patterns too much and create that confusion in our solution, plus there are cases where our server already has to do the work for other reasons and it makes sense to leverage the fact that we have the data rather than do some additional ajax calls that are completely unneeded.

As a hack and stopgap, I have occasionally had the server render a json object into a javascript global variable and done $scope.data= _my_ugly_global_variable;//tears and crying here.

I have some ideas for better ways to handle the issue, but I am not always happy with them.

Furthermore, it leads me to a different question. If I want to have two instances of a given angular view, but I want them to each have independent data, what's the best way to do that? How do I inform the controller function that one instance should get dataA while instance two should get dataB?

Again, I have some ideas that I could work on, but I don't really want to reinvent the wheel on this if there are some elegant solutions that people can share.

thanks,

Danny
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900