私のウェブページはサーバ上のファイルのリストを表示し、ファイル名の隣には「インストール」ボタンがあります。 「インストール」をクリックすると、インストールする対応ファイルの名前をサーバーが受け取るはずです。私の現在のコードはサーバーへのファイルのpsas名にできません。あなたは、ボタンをクリックするとファイルの名前をサーバーに送る方法をお勧めしますか?ボタンをクリックしてインストールするファイルの名前をangularjsでクリック
は、ここに私のコード
app.controller('RdaController', ['$scope', 'RdaService',
function($scope, RdaService) {
$scope.greeting = "Hello world";
$scope.file = "installJob.zip";
$scope.sendToCTP = function($scope) {
return RdaService.SendFileToCTP($scope);
};
}
]);
app.service('RdaService', ['$http',
function($http) {
this.SendFileToCTP = function($scope) {
return $http({
method: "GET",
url: "../api/CTP/installJobFromFile/" + $scope.file,
headers: {
'Content-Type': 'application/json'
}
}).success(function(data) {
//$scope.sendToCTP = data;
console.log(data);
}).error(function(data) {
console.log(data);
});
};
}
]);
<h2>List of Files available</h2>
<table class="table table-striped">
<tr ng-repeat="file in listOfFiles">
<td>{{ file }}</td>
<td><span class="btn-group" role="group"><button type="button" class="btn btn-default" ng-click="sendToCTP(file)">install</button><button type="button" class="btn btn-default">delete</button></span>
</td>
</tr>
</table>
おかげでたくさん!これは動作します –