I have a sample application which can store values into local storage when user clicks to local button but i want to all values from the txt file to be in local storage "note2": [] .
Plunker Demo
I have a sample application which can store values into local storage when user clicks to local button but i want to all values from the txt file to be in local storage "note2": [] .
Plunker Demo
To put your data in localStorage in angularJS you can use the library angular-localForage.
Example:
angular.module('yourModule', ['LocalForageModule'])
.controller('yourCtrl', ['$scope', '$localForage',
function($scope,$localForage) {
$localForage.setItem('myName','Olivier Combe').then(function() {
$localForage.getItem('myName').then(function(data) {
var myName = data;
});
});
}]);
And yes i found a way to do so .,
you can use ng-init='Function name'
here i use a function when a user click the to local button to push a value to local
$scope.cloneItem = function (todo) {
$scope.$storage.notes.push({
"price": todo.price,
"id": todo.id,
"quan": todo.quan
});
}
but i want to store all the values from the txt file to local so i use
ng-init='your js function name'
this function to call push function so that for every ng-repeat the value would push to local
Example :
<tr ng-repeat="todo in todos" ng-init='cloneItem(todo)'>