javascript - How do I remove a specific element from local storage array in Angularjs? -


here's html:

 <tr ng-repeat="student in students track $index">              //some code here            <button ng-click="remove(student)">delete</button>             </td>         </tr> 

and here's .js file code deleting student(not local storage):

$scope.remove = function(student) {     var index = $scope.students.indexof(student);     $scope.students.splice(index, 1); } 

how access local storage js code , delete particular student local storage.

sounds should rephrase question "how access browser's local storage js code?"

you can access localstorage in js code localstorage. delete student $scope.students , when finished, set new array item in local storage:

$scope.remove = function(student) {     var index = $scope.students.indexof(student);     $scope.students.splice(index, 1);     localstorage.setitem('students', json.stringify($scope.students)); } 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -