0
我正在嘗試檢索遠程服務器上的文件列表,並將它們顯示在網頁上。 作用域變量fileListOnCTP
包含從網頁訪問的文件列表。但是網頁不顯示文件列表。但是ng-inspector顯示了保存正確值的變量。有人能告訴我我哪裏可能會出問題嗎?無法從HTML中訪問範圍變量
$scope.listOfFilesOnCTP = "";
\t $scope.fileListOnCTP = "";
\t $scope.GetListOfFilesonCTP = function(path){
\t $scope.listOfFilesOnCTP = RdaService.getListOfFilesonCTP(encodeURIComponent(path)).then(function(response){
\t \t \t var newData = response.data;
\t \t \t console.log(newData);
\t \t \t return newData;
\t \t });
\t console.log($scope.listOfFilesOnCTP); // --> Displaying the file list correctly
\t \t //path = path.replace(/\//g, '_');
\t $scope.fileListOnCTP = $scope.listOfFilesOnCTP;
\t };
\t <div class="col-md-3" id="CTP Jobs">
\t \t <h3>JOBS</h3>
\t \t <table class="table table-striped">
\t \t \t <div ng-model="fileListOnCTP" ng-init="GetListOfFilesonCTP('/home/topas/rda_app/JOBS')">
\t \t \t \t <span><tr>{{fileListOnCTP}} <!-- Variable not getting resolved although it shows correct value in controller -->
\t \t \t \t \t </tr></span>
\t \t \t </div>
\t \t </table>
\t </div>
,你不能只是簡單的做一個'ngModel'上一個DIV,只有輸入/ textarea的(除非您使用需要'ngModel'一個指令) –
如果返回值是一個數組,你可能想要一個ng-repeat。什麼是fileListOnCTP的類型? – BobS
感謝您的反饋..但我沒有運氣,沒有使用ng-model。 –