How do i render django json view with angularjs $resource? -
I just completed Angularjs tutorial and try to integrate it with Django.
For my problem, I looked around and found a problem with me, but the problem was never resolved.
My demo view;
View class MyView (): get def (self, request, * Arges, ** kwargs): data = serializers.serialize ( 'json', Srenikobajeskol ()) Acteepiarpispakshn (Data, Content_type = "App / JS") App.JS
app ('Categories', ['$ resource', function ($ resource) {return $ resource ('/ categories');}]); App.controller ( 'mainCtrl', [ '$ scope', 'Categories', function ($ scope, categories) {$ scope.test = "test"; $ scope.categories = category.query ();}); }]; Calling on \ categories gives me the correct Jason response The test value fixes but the data in the categories is not rendered
Solution: Check my answer.
About getting it this way:
$ http ({method: 'GET', url: /categories'}).success(function(data) {$ scope.categories = data;});
Comments
Post a Comment