|
|
@@ -1,9 +1,12 @@
|
|
|
-app=angular.module('app', []);
|
|
|
+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) {
|
|
|
@@ -21,6 +24,22 @@ app.controller('main', function($scope,$http,$sce) {
|
|
|
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) {
|
|
|
@@ -31,7 +50,8 @@ app.controller('main', function($scope,$http,$sce) {
|
|
|
);
|
|
|
};
|
|
|
$scope.filter = function() {
|
|
|
- $http.post("/pymnts/articles/",{"mindate":$scope.mindate,"maxdate":$scope.maxdate,"site":$scope.site,"keyword":$scope.keywod,"minweight":$scope.minweight}).then(
|
|
|
+ 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;
|
|
|
},
|