Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How to store contacts in localstorage (AngularJS)

I was given the task of storing contacts from the form to localstorage. What is the best way to do this? I have tried several options but it is not clear to me which value should be for value and which for key? This is the script.js code:

var app = angular.module("addrBook",[]);
        app.controller("myCtrl",function($scope){
            $scope.info = [
                {name:"Pera",tel:"2145466547457"},
                {name:"Sima",tel:"534654756865634"},
                {name:"Mika",tel:"2355765864578"}
            ];
           
            $scope.addMe = function(){
                return {
                    name: $scope.newName,
                    tel:$scope.newTel
                }
            }
            $scope.addItem = function(){
             for(var i=0;i<$scope.info.length;i++){
                 if(($scope.info[i].name == $scope.addMe().name)||
                    ($scope.info[i].tel == $scope.addMe().tel)){
                     alert("name or telphone number was repeated");
                     return false;
                 }
             }
             $scope.info.push($scope.addMe());
              }
                
 
            $scope.removeItem = function(){
                $scope.info.splice(this.$index,1)
            }
       
            $scope.change = function(){
              index = this.$index;
              $scope.showMe = function(indx){
                  if(indx == index){
                   return true;                 
                  }
              }    
            }
            $scope.save = function(){
              index = this.$index;
              $scope.showMe = function(indx){
                  if(indx == index){
                   return false;                 
                  }
              }    
            }            
        })
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!