I am new to AngularJS and am trying to push the property value of an object when it is changed in my app. For instance:
List 1
<ul>
<li ng-repeat="item in items | filter : {selected: false}">
{{ item.name }}
<a href="#" ng-click="move(item)">move</a>
</li>
</ul>
List 2
<ul>
<li ng-repeat="item in items | filter : {selected: true}">
{{ item.name }}
<a href="#" ng-click="move(item)">move</a>
</li>
</ul>
So in this app, when I click "move" it changes the selected property to true or false. However in the DB this is not reflected. How can I post these as AJAX requests to achieve persistence?
You can use $http to make an ajax call before changing the item's state. Something like...
$scope.move = function(item) {
var newState = !item.selected;
$http.post(someurl, item).success(function() {
item.selected = newState;
});
};