0
私はDjangoからAPIを取得し、データを取得してHTMLで可視化するウェブサイトを持っています。今はウェブサイトに入るたびに保存したいので、ページを更新したりサーバーを閉じると消えませんが、テーブルに導入されます。
これは、データを取得するためにAPIを使用するための私のコードは次のとおりです。
angular
.module('inspinia')
.controller('ListWebsiteCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.set = function (new_url) {
$scope.data = new_url;
$http.post("http://127.0.0.1:8000/api/website/" + this.get_url.url).success(function (data) {
$scope.websites = data.websites;
});
};
}]);
これは私のHTMLです:
<form ng-controller="ListWebsiteCtrl">
<input title="get_url.url" ng-model="get_url.url">
<button ng-click="set(get_url.url)">INSERT WEBSITE</button>
<table class="table">
<tr>
<th>ID</th>
<th>URL</th>
<th>Status</th>
</tr>
<tr>
<th>{{ websites.id }}</th>
<th>{{ websites.url }}</th>
<th>{{ websites.status }}</th>
</tr>
</table>
</form>
それを行うための最も効率的な方法は何ですか?
クライアント側にデータを保存する場合は、ブラウザ[ローカルストレージ](https://www.w3schools.com/html/html5_webstorage.asp)を使用できます。しかし、リフレッシュ後にデータをロードする場合は、サーバーが稼動している必要があります。 – anuragal