Jon*_*ono 10 javascript model-view-controller angularjs meteor
所以我对这两种技术都很陌生.我的计划是使用Backbone(https://github.com/philipkobernik/backbone-tunes)与MeteorJS 一起实现Peepcode Tunes项目,然后尝试使用带有AngularJS插件的MeteorJS实现它.有人已经在Angular中完成了所有工作:https://github.com/angular/peepcode-tunes
大多数事情进展顺利.你可以看到我到目前为止所拥有的:
Just Meteor:https://github.com/Jonovono/Meteor-peepcode-tunes Meteor和AngularJs:https://github.com/Jonovono/Meteor-angular-peepcode-tunes
我非常喜欢使用Angular并且能够从视图中传递信息,例如:
ng-click="pl.add(album)">
Run Code Online (Sandbox Code Playgroud)
当使用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();
};
Run Code Online (Sandbox Code Playgroud)
但是,这似乎并没有将其保存到数据库中.但是,如果我要做的事情如下:
album.title = "CHANGED"
album.$save()
Run Code Online (Sandbox Code Playgroud)
好像它会将其保存到数据库中.
我确信我只是遗漏了一些关于Meteor或AngularJS的小东西.任何启蒙都会很棒!
小智 22
这座桥的创造者.你从github上下载了最新版本吗?我还没有更新气氛版本.对不起..findOne需要一些额外的代码才会推迟今晚.
https://github.com/lvbreda/Meteor_angularjs