Sunday 15 June 2014

angularjs - button deselect not splicing data out of json object -



angularjs - button deselect not splicing data out of json object -

i have rows of button pairs created ng-repeat. when button in each row clicked, changes color (green) show has been toggled , info associated button pushed json object array. have function removes object array. want happen if other button in row pressed, not info in json array removed, info in button loaded in place. far i'm having problem making work.

html:

<div class="form-horizontal" data-ng-repeat="item in event.events track $index"> <div class="col-xs-12 col-md-6 col-lg-6"> <button type="button" class="btn form-control" data-ng-class="[pickchosen == 1 ? 'btn-success' : 'btn-default']" data-ng-click="buttontoggle($index, 1); makepick(item.eventid, event.memberid, item.awayid)"> </button> </div> <div class="col-xs-12 col-md-6 col-lg-6"> <button type="button" class="btn form-control" data-ng-class="[pickchosen == 2 ? 'btn-success' : 'btn-default']" data-ng-click="buttontoggle($index, 2); makepick(item.eventid, event.memberid, item.homeid)"> </button> </div> </div>

angular:

var picks = $scope.picks = []; $scope.buttontoggle = function(index, buttonnumber) { this.pickchosen = buttonnumber === this.pickchosen ? 0 & $scope.removepick(index) : buttonnumber; }; $scope.makepick = function (eventid, memberid, teamid) { picks.push({ "eventid": eventid, "memberid": memberid, "teamid": teamid }); }; $scope.removepick = function(index) { picks.splice(index, 1);

right stands, if click different button, new object added array, old 1 isn't deleted. wonder if can help solution. thanks.

angularjs

No comments:

Post a Comment