【发布时间】:2016-07-07 03:57:57
【问题描述】:
我在我的 Angular 应用程序中使用 browserify。我阅读了一些关于 falcor 的文章并决定进行测试,但在我的应用程序中注入它时遇到问题。所以我通过 npm 安装了 falcor,我试图像这样注入它:
require('falcor');
var app = angular.module('app', ['ui.router', 'login', 'falcor'];
但我收到:Failed to instantiate module falcor due to 错误。
以后在我的服务中,我的想法是做这样的事情:
app.service('loginService', function(falcor) {
function falcor() {
var model = new falcor.Model({
cache: {
events: [
{
name: "ng-conf",
description: "The worlds best Angular Conference",
location: { city: "Salt Lake City", state: "Utah" }
},
{
name: "NodeConf",
description: "NodeConf is the longest running community driven conference for the Node community.",
location: { city: "Walker Creek Ranch", state: "California" }
}
]
}
});
model
// We want the name and description values for the first three items
// from the data model
.get(["events", {from: 0, to: 2}, ["name", "description"]])
.then(function(response) {
});
}
return {
falcor: falcor
}
});
所以我的问题是如何正确注入 falcor 以便我可以在我的应用程序中使用它?几乎没有关于使用 angular 和 falcor 的例子,所以我很困惑。
我找到了一个 npm 包 - ng-falcor,但由于没有示例,只有一些关于 api 的基本描述,我决定跳过它。
【问题讨论】: