app.js 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. app=angular.module('app', []);
  2. app.controller('main', function($scope,$http) {
  3. $scope.list=[];
  4. $scope.book="";
  5. $scope.extension="";
  6. $scope.getList = function() {
  7. $http.get("/test/").then(
  8. function(data) {
  9. /*
  10. data.data=data.data.map(function(el) {
  11. if (el.STATUS!="DISCONNECTED")
  12. el.STATUS=el.STATUS+" "+el.ELAPSED;
  13. return el;
  14. });
  15. */
  16. $scope.list=data.data;
  17. },
  18. function(data){
  19. console.log("error");
  20. console.log(data);
  21. });
  22. }
  23. $scope.getList();
  24. $scope.download = function(book) {
  25. $http.post("/test/?adasasd",{"type":"BOOK","book":book}).then(
  26. function(data) {
  27. $scope.getList();
  28. },
  29. function(data){
  30. console.log("error");
  31. console.log(data);
  32. });
  33. };
  34. $scope.searchBook = function(book,extension){
  35. $http.post("/test/?ewqewqewq", {"type":"search","book":book,"extension":extension}).then(
  36. function(data) {
  37. console.log("success");
  38. $scope.getList();
  39. },
  40. function(data){
  41. console.log("err");
  42. });
  43. };
  44. });