app.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. app=angular.module('app', []);
  2. app.controller('main', function($scope,$http,$sce) {
  3. $scope.news=[];
  4. $scope.newsArticle="";
  5. $scope.getNews = function() {
  6. $http.get("/pymnts/articles/").then(
  7. function(data) {
  8. /*
  9. data.data=data.data.map(function(el) {
  10. if (el.STATUS!="DISCONNECTED")
  11. el.STATUS=el.STATUS+" "+el.ELAPSED;
  12. return el;
  13. });
  14. */
  15. $scope.news=data.data.articles;
  16. },
  17. function(data){
  18. console.log("error");
  19. console.log(data);
  20. });
  21. };
  22. $scope.getArticle = function(el) {
  23. $http.get("/pymnts/article/"+el._id).then(
  24. function(data) {
  25. $scope.newsArticle=$sce.trustAsHtml(data.data.articles.html);
  26. },
  27. function(data){
  28. }
  29. );
  30. };
  31. $scope.filter = function() {
  32. $http.post("/pymnts/articles/",{"mindate":$scope.mindate,"maxdate":$scope.maxdate,"site":$scope.site,"keyword":$scope.keywod,"minweight":$scope.minweight}).then(
  33. function(data) {
  34. $scope.news=data.data.articles;
  35. },
  36. function(data) {
  37. }
  38. );
  39. };
  40. $scope.getNews();
  41. /*
  42. $scope.download = function(book) {
  43. $http.post("/test/?adasasd",{"type":"BOOK","book":book}).then(
  44. function(data) {
  45. $scope.getList();
  46. },
  47. function(data){
  48. console.log("error");
  49. console.log(data);
  50. });
  51. };
  52. $scope.searchBook = function(book,extension){
  53. $http.post("/test/?ewqewqewq", {"type":"search","book":book,"extension":extension}).then(
  54. function(data) {
  55. console.log("success");
  56. $scope.getList();
  57. },
  58. function(data){
  59. console.log("err");
  60. });
  61. };
  62. */
  63. });