如何存储和在anguar js的检索数据? [英] how to store and retrieve data in anguar js?

查看:152
本文介绍了如何存储和在anguar js的检索数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以请你告诉我如何存储数据permantly(例如本地存储)和检索数据。我想存储数据,使我得到一次。我在做客户端编程?我谷歌它,它说有persistance.js会做..can我们使用呢?我尝试做一个简单的例子来存储数据,但不能说。我要保存学生和班级的名称列表。
这里是我的plunker: http://plnkr.co/edit/cLTIJfETGYENQyEdsu94?p=preVIEW

can you please tell me how to store data permantly (example local storage)and retrieve data .I want to store data so that I get again .I am doing client side programing ? I google it it say there is persistance.js will do that ..can we use that ?I am try to make a simple example to store data but not able to that .I want to save list of name of student and class. here is my plunker : http://plnkr.co/edit/cLTIJfETGYENQyEdsu94?p=preview

 // Code goes here
    var app = angular.module('appstart', ['ngRoute']);

    app.config(function($routeProvider) {
      //  $locationProvider.html5Mode(true);
      $routeProvider
        .when('/home', {
          templateUrl: 'tem.html',
          controller: 'ctrl'
        })


      .otherwise({
        redirectTo: '/home'
      });
    });

    app.controller("ctrl", function($scope) {

      $scope.students = [];

      $scope.add = function() {

        $scope.students.push({
          inputName : angular.copy($scope.inputName),
          inputclass : angular.copy($scope.inputclass)
        });

        $scope.inputclass='';
        $scope.inputName='';
        }

    }
    );

感谢

推荐答案

您需要一个数据库。网络存储是只是暂时的事情。

You need a database. Web-storage is only for temporary things.

如果你有一个后端,您可以使用一个服务, $ HTTP 以创建一个CRUD应用程序。

If you have a backend, you can use a service and $http to create a CRUD application.

您使用的角度将数据发送到由它来完成持久性后端。

You use Angular to send data to the backend which does the persistence.

这篇关于如何存储和在anguar js的检索数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆