10

所以我对这两种技术都很陌生。我的计划是使用 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 添加到它的小东西。任何启蒙都会很棒!

4

3 回答 3

22

这里的桥梁的创造者。你是从 github 上拉最新版本的吗?我还没有更新关于气氛的版本。对不起。.findOne 需要一些额外的代码,今晚会推送它。

https://github.com/lvbreda/Meteor_angularjs

于 2012-11-02T22:15:30.800 回答
2

新桥的创建者在这里:)

由于不再维护旧桥,我们的团队编写并积极维护这个库 - angular-meteor,我们还发布了一个结合两者的教程 - angular-meteor 教程

很想听听你的想法!

于 2014-10-07T22:25:23.890 回答
0

你可以使用Uri提到的角度流星+你可以看到更多可用的 角度模块

于 2015-07-19T19:36:55.567 回答