-
Notifications
You must be signed in to change notification settings - Fork 619
Closed
Description
The first change to an array is only registered locally and not pushed to the server if I use a $meteor.collection and try to push to an array that is a member of an item in the collection (I'm NOT saving or removing a new party from the collection, but editing an array that is a member of a party),
I've pasted my code below.
party.ng.js
============
angular.module('parties', ['angular-meteor', 'ui.router']);
angular.module('parties').controller('PartyController', function($scope, $meteor) {
var ctrl = this;
ctrl.newPartyName = "";
ctrl.parties = $meteor.collection(Parties);
ctrl.createParty = function() {
ctrl.parties.save({
name: ctrl.newPartyName,
randomNumbers: []
});
ctrl.newLeagueName = '';
};
// Join a league (submit a request to join)
ctrl.addToPartyArray = function(party) {
party.randomNumbers.push(Math.random());
};
ctrl.removeFromPartyArray = function(party) {
party.randomNumbers.splice(0, 1);
};
});
index.ng.html
================
<div ng-controller="PartyController as partyCtrl">
<ul>
<li ng-repeat="party in partyCtrl.parties">{{party.name}}
<p ng-repeat="num in party.randomNumbers">{{num}}</p>
<button type="submit" ng-click="partyCtrl.addToPartyArray(party)">Add Random Num</button>
<button type="submit" ng-click="partyCtrl.removeFromPartyArray(party)">Remove Random Num</button>
</li>
</ul>
<form name="createPartyForm" ng-submit="createPartyForm.$valid && partyCtrl.createParty()" novalidate>
<input ng-model="partyCtrl.newPartyName" type="text" placeholder="Party Name" required>
<button type="submit" ng-class="{ disabled : !createLeagueForm.$valid }">Create Party</button>
</form>
</div>
Metadata
Metadata
Assignees
Labels
No labels