繁体   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