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 [email protected].
For more options, visit https://groups.google.com/d/optout.