app=angular.module('app', ["ngTagsInput"]); app.controller('main', function($scope,$http,$sce) { $scope.news=[]; $scope.newsArticle=""; $scope.keywords=[]; $scope.selected_kw=[]; $scope.getNews = function() { $http.get("/pymnts/articles/").then( function(data) { /* data.data=data.data.map(function(el) { if (el.STATUS!="DISCONNECTED") el.STATUS=el.STATUS+" "+el.ELAPSED; return el; }); */ $scope.news=data.data.articles; }, function(data){ console.log("error"); console.log(data); }); }; $scope.filtered = function(q) { q=q.toLowerCase(); return $scope.keywords.filter(function(e) { return e.toLowerCase().indexOf(q) > -1}); }; $scope.getKeywords = function() { $http.get("/pymnts/keywords").then( function(data) { //$scope.keywords=data.data.keywords.map(function(e) { return {text:e} }); $scope.keywords=data.data.keywords; }, function(data){ } ); }; $scope.getKeywords(); $scope.getArticle = function(el) { $http.get("/pymnts/article/"+el._id).then( function(data) { $scope.newsArticle=$sce.trustAsHtml(data.data.articles.html); }, function(data){ } ); }; $scope.filter = function() { var kw = $scope.selected_kw.map(function(e){return e.text}); $http.post("/pymnts/articles/",{"mindate":$scope.mindate,"maxdate":$scope.maxdate,"site":$scope.site,"keyword":kw,"minweight":$scope.minweight}).then( function(data) { $scope.news=data.data.articles; }, function(data) { } ); }; $scope.getNews(); /* $scope.download = function(book) { $http.post("/test/?adasasd",{"type":"BOOK","book":book}).then( function(data) { $scope.getList(); }, function(data){ console.log("error"); console.log(data); }); }; $scope.searchBook = function(book,extension){ $http.post("/test/?ewqewqewq", {"type":"search","book":book,"extension":extension}).then( function(data) { console.log("success"); $scope.getList(); }, function(data){ console.log("err"); }); }; */ });