簡體   English   中英

如何使用set和$ http.post保存在AngularJS中

[英]How to save in AngularJS using set and $http.post

我有一個網站,該網站從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>

最有效的方法是什么?

使用索引數據庫這是用於客戶端存儲大量結構化數據(包括文件/ blob)的低級API。 該API使用索引來啟用對此數據的高性能搜索。 Web存儲可用於存儲少量數據,而對存儲大量結構化數據則不太有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM