所以我对这两种技术都很陌生。我的计划是使用 MeteorJS 实现他们使用 Backbone ( https://github.com/philipkobernik/backbone-tunes ) 制作的 Peepcode Tunes 项目,然后尝试使用 MeteorJS 和 AngularJS 插件来实现它。有人已经在 Angular 中完成了这一切:https ://github.com/angular/peepcode-tunes
大多数事情都进行得很顺利。你可以看到我到目前为止在:
只是流星:https ://github.com/Jonovono/Meteor-peepcode-tunes 流星和 AngularJs:https ://github.com/Jonovono/Meteor-angular-peepcode-tunes
我真的很喜欢使用 Angular 并能够从视图中传递一些东西,例如:
ng-click="pl.add(album)">
仅使用 Meteor 时,这似乎更复杂。
但是我有一个问题。假设我想在每次添加/删除专辑时保存播放列表。因此,如果页面被刷新,它仍然存在。我不知道做到这一点的最佳方法,当使用 AngularJS 和 Meteor 时,我很困惑应该如何做到这一点。
现在在使用 Angular 和 Meteor 时,我会做这样的事情:
$scope.Playlist = new Meteor.AngularCollection("playlist", $scope);
$scope.playlist = $scope.Playlist.findOne({});
$scope.pl.add = function(album) {
if ($scope.playlist.indexOf(album) != -1) return;
$scope.playlist.push(album);
$scope.playlist.$save();
};
但是,这似乎并没有将其保存到数据库中。但是,如果我要执行以下操作:
album.title = "CHANGED"
album.$save()
似乎它会将其保存到数据库中。
我确信我只是错过了一些关于 Meteor 或 AngularJS 添加到它的小东西。任何启蒙都会很棒!