Skip to content

Instantly share code, notes, and snippets.

@tomodutch
Last active August 29, 2015 14:24
Show Gist options
  • Save tomodutch/b55d8eafbbe8c85b0c4b to your computer and use it in GitHub Desktop.
Save tomodutch/b55d8eafbbe8c85b0c4b to your computer and use it in GitHub Desktop.
angular1 vs angular2-now
angular.module('app').controller(['$meteor, $scope', function() {
$scores = $meteor.collection(Scores).subscribe('scores');
$scope.amount = '';
$scope.insertScore = function() {
$scores.call('insertScore', $scope.amount);
}
$scope.resetAmount = function() {
$scope.amount = '';
};
}]);
@Component({selector: 'create-score-form'})
@View({templateUrl: 'client/scores/create/create.ng.html'})
@Inject(['ScoreService'])
class CreateScoreCtrl {
constructor(ScoreService) {
this.service = ScoreService;
this.amount = '';
}
insertScore() {
this.service.insertScore(this.amount);
this.resetAmount();
}
resetAmount() {
this.amount = '';
}
}
Scores = new Meteor.Collection('scores');
if (Meteor.isClient) {
@Service('ScoreService')
@Inject(['$meteor'])
class ScoreService {
constructor($meteor) {
this.$meteor = $meteor;
this._collection = this.$meteor.collection(Scores).subscribe('scores');
}
findAll() {
return this._collection
}
@MeteorMethod()
insertScore(amount) {
this.$meteor.call('insertScore', amount);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment