所以我对这两种技术都很陌生。我的计划是用 MeteorJS 实现他们用 Backbone ( https://github.com/philipkobernik/backbone-tunes ) 制作的 Peepcode Tunes 项目,然后尝试用 MeteorJS 和 AngularJS 插件实现它。有人已经在 Angular 中完成了这一切:https://github.com/angular/peepcode-tunes
大部分事情都进行得很顺利。您可以在以下位置查看我目前拥有的内容:
只是 meteor :https://github.com/Jonovono/Meteor-peepcode-tunes meteor 和 AngularJs:https://github.com/Jonovono/Meteor-angular-peepcode-tunes
我真的很喜欢使用 Angular 并能够从 View 中传递东西,例如:
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 的小东西。任何启示都会很棒!
最佳答案
这里是桥梁的创造者。你是从github上拉取最新版本的吗?我还没有更新大气版本。对不起。 .findOne 需要一些额外的代码,今晚将推送它。
关于javascript - 将 AngularJS 与 MeteorJS 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13150826/