Meteor + AngularJs的例子

Joh*_*iss 12 angularjs meteor angular-meteor

我是Meteor和AngularJs的新手.我试图按照https://github.com/lvbreda/Meteor_angularjs上的示例应用程序,但到目前为止我还没有能够使它工作.

我在这段代码中收到错误'app is not defined':

app.controller('MeteorCtrl', ['$scope', '$meteor', function ($scope, $meteor) {
Uncaught ReferenceError: app is not defined
    $scope.todos = $meteor("todos").find({});
    $meteor("todos").insert({
        name: "Do something",
        done: false
    });
Run Code Online (Sandbox Code Playgroud)

我试着重写上面的内容:

var MeteorCtrl = function ($scope, $meteor) {
    $scope.todos = $meteor("todos").find({});
    $meteor("todos").insert({
        name: "Do something",
        done: false
    })
};
Run Code Online (Sandbox Code Playgroud)

仍然抛出错误'错误:未知提供商:$ meteorProvider < - $ meteor'

https://github.com/bevanhunt/meteor-angular-leaderboard上唯一的另一个米+角度示例似乎已过时.

有人可以使用https://github.com/lvbreda/Meteor_angularjs上的软件包发布一个简单但完全可以下载的meteor + angularjs示例吗?

Uri*_*igo 7

我显然有偏见,但我们的团队编写并维护了这个库 - 角度流星,我们还发布了一个结合两个角度教程的教程 - 角度流星教程


akn*_*ds1 5

虽然我没有使用lvbreda的Angular包,但我能够以相对简单的方式将Angular与Meteor + Blade集成为HTML模板语言.我从Daniel Olano的Ng-Meteor软件包开始,最终得到了我自己实现的Meteor/Angular桥.我是Meteor和Angular的新手,但它看起来效果很好,我觉得代码非常透明,所以我很清楚它是如何工作的.

我编写了以下CoffeeScript模块,名为client/ngMeteor.coffee,它定义了Meteor和Angular之间的桥梁:

define("ngMeteor", [], ->
  angular.module('ngMeteor.directives', [])

  angular.module('ngMeteor.services', [])

  angular.module('ngMeteor.blade', []).run(['$templateCache', '$rootScope', '$compile',
    ($templateCache, $rootScope, $compile) ->
      bodyTemplate = Template.body
      if !bodyTemplate
        throw new Error("A body template must be defined ('body.blade')")

      # Render each template and place in Angular's template cache
      $templateCache.put "#{key}.blade", render() for own key, render of Template

      # Render the body template and have Angular compile it, then inject it into the DOM's body element
      Meteor.startup(()->
        # Necessary?
        Spark.finalize(document.body)
        $('html').attr('data-ng-app', '')
        $('body').html($compile(bodyTemplate())($rootScope))
        $rootScope.$apply()
      )
  ])
  angular.module 'ngMeteor', ['ngMeteor.blade', 'ngMeteor.services', 'ngMeteor.directives']
)
Run Code Online (Sandbox Code Playgroud)

有关完整的工作示例,请参阅我的示例项目.反馈表示赞赏.

  • 很高兴看到它对某人有用,我开始为一个个人项目,但后来我不得不在别的地方工作.我想我很快就会恢复这个项目,所以它可以有更多的功能. (2认同)

coo*_*xeo 2

您可以在不同的分支中找到一些示例 https://github.com/alex-okrushko/Meteor_angularjs

我在https://github.com/linepos/linepos中构建了一个应用程序,但现在它不起作用,因为 lvbreda 更改了代码

您可以使用另一种方法https://github.com/kievechua/flame-on