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示例吗?
虽然我没有使用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)
有关完整的工作示例,请参阅我的示例项目.反馈表示赞赏.
您可以在不同的分支中找到一些示例 https://github.com/alex-okrushko/Meteor_angularjs
我在https://github.com/linepos/linepos中构建了一个应用程序,但现在它不起作用,因为 lvbreda 更改了代码
您可以使用另一种方法https://github.com/kievechua/flame-on
| 归档时间: |
|
| 查看次数: |
11871 次 |
| 最近记录: |