How to send list of files to angularjs options from node.js?

老子叫甜甜 提交于 2019-12-12 02:45:03

问题


I am getting files from directory('app/jsonfiles') in node.js, and I am not sure how can I send this list of files to my front-end as options in select list to write one common get request for getting the data of selected file.

partial Plnkr. Please let me know that how can I get my list of files in my angular from my server.js to display in my dropdown and Thanks in advance for help !


回答1:


Inject Main service into MainCtrl and call the service.

  var app = angular.module('plunker', [MainService]);
    app.controller('MainCtrl', function($scope,$http, $timeout, Main) {
    $scope.JSONFiles = [];

    Main.get().success(function(data){
     data.forEach(function(obj){
      $scope.JSONFiles.push(obj);
     })
     });
    $scope.selectedjson ="";
    $scope.textAreaData = "";
    $scope.optionChanged = function(){
      $scope.textAreaData = $scope.selectedjson;
    }

    });


来源:https://stackoverflow.com/questions/39849899/how-to-send-list-of-files-to-angularjs-options-from-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!