I got angular to call web2py controller methods passing data both ways by using the older web2py approach not using '@... restful' decorators. So in the $http.get I pass the full URL such as 'http://127.0.0.1:8000/ welcome/default/api/auth_user/1'
On Tuesday, July 12, 2016 at 6:45:40 AM UTC-4, botass...@gmail.com wrote: > > Hello everyone. > > Can someone explain me how to get data from table using web2py rest api > and angularjs? > I have function api(): > > > 1. @request.restful() > 2. def api(): > 3. response.view = 'generic.json' > 4. def GET(*args,**vars): > 5. patterns = 'auto' > 6. parser = db.parse_as_rest(patterns,args,vars) > 7. if parser.status == 200: > 8. return dict(content=parser.response) > 9. else: > 10. raise HTTP(parser.status,parser.error) > 11. def POST(table_name,**vars): > 12. return db[table_name].validate_and_insert(**vars) > 13. def PUT(table_name,record_id,**vars): > 14. return db(db[table_name]._id==record_id).update(**vars) > 15. def DELETE(table_name,record_id): > 16. return db(db[table_name]._id==record_id).delete() > 17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE) > > > i have defined table: > db.define_table('test', Field('something','text')) > > I understand that i should make angular controller and use $http.get(' > http://127.0.0.1:8000/myapp/default/api/test'), and then put it in > $scope.text = data > which will be called from my view by [[text.content]]. But all samples i > found and all tries i made failed or i just got an empty page. > > please give me an example how to communicate with web2py api by angularjs. > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.