Problem with http queue
Issue #2
resolved
Hey,
I have a problem with dynamic loading. After calling http post not load data into a form, but if loads data before http post, the form is loaded correctly.
Comments (4)
-
repo owner -
reporter my solution is
/** * Controller */ // http request var request = requestHandler.request('POST', '/ajax/view/users/edit/', {}); // http response request.then(function(data) { $scope.createForm = data; });
/** * dynamic-forms.js */ ...... return { restrict: 'E', // supports using directive as element only link: function($scope, element, attrs) { var test = function() { // Basic initialization var newElement = null, newChild = null, optGroups = {}, cbAtt = '', foundOne = false, iterElem = element, model = null; ............. } $scope.$watch("createForm", function(val) { if (val != undefined) { console.log(val); test(); } }); } };
-
repo owner Ah, the third. Yes, that is the only real solution. Just as with any template used by Angular, if you need to retrieve it via POST, you'll have to retrieve it in your code. Angular templates are all GET based.
A large part of this is the fact that Angular expects a RESTlike interface with the server. GET to retrieve data, POST to update it. If you have control over the server-side logic, this is generally the best way to go.
-
repo owner -
assigned issue to
- changed status to resolved
Closing this because it seems like this has been resolved. Feel free to reopen it if you need to!
-
assigned issue to
- Log in to comment
I don't quite follow. It sounds like the form template loads properly most of the time, but fails to when the current page is the response to an HTTP POST request, such as after submitting a form. Another interpretation I can see is that it loads fine unless Angular makes a POST request via XHR before it attempts to load the form template. Then again, you might also be saying that it works unless you need to retrieve the template itself via POST instead of GET. I'm not sure which of these, if any, to address.