There is an example on using TG with Angular at
http://turbogears.readthedocs.org/en/latest/cookbook/Crud/restapi.html#leveraging-your-rest-api-on-angularjs
did you check it that works for you?

You might want to compare how $resource and your $http call send that to
check for differences.



On Thu, Jul 3, 2014 at 1:21 AM, Barry Loper <[email protected]> wrote:

> Hi there. I'm having trouble using the RestController with AngularJS. I've
> looked through the tutorial on using Angular with EasyCrudRestController,
> but if there was a solution to my problem in there, I'm not finding it. It
> could just be my lack of experience that is stumping me, but hopefully
> someone on here can help me.
>
> The bottom line is that I submit some application/json data with a PUT or
> POST, but my **kw in my controller is empty. The data is available in
> tg.request.body, but I'm not sure if that can be accessed by an @validate
> decorator.
>
> My Angular request looks like this:
>
>>   $http({
>>
>>             'method': 'PUT',
>>
>>             'url': '../api/entity.json',
>>
>>             'data': $scope.entity,
>>
>>             'responseType': 'application/json'
>>
>>         } )
>>
>>
> My  request payload as shown by Chrome looks like json. I've tried doing
> angular.fromJson($scope.entity) and even angular.toJson(), but Turbogears
> isn't able to populate the **kw dict with the json data.
>
> In the debug log, I can see the data is coming through by printing out
> json.loads(request.body). printing out kw, gets me {}.
>
> The only workaround so far is to pass the POST/PUT info in 'params'. I'd
> rather not. Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to