问题
I try to use breeze in Angular with MongoLab Api in plunkr.
var dataService = new breeze.DataService({
serviceName: "https://api.mongolab.com/api/1/databases/webuniversite?apiKey=apikey",
hasServerMetadata: false,
});
var manager = new breeze.EntityManager({ dataService: dataService });
I get "Origin http://run.plnkr.co is not allowed by Access-Control-Allow-Origin. " message.
Any idea for use of MongoLab together with Breezejs.
回答1:
We're not ready for MongoDb yet. Almost. Very soon. There is mongo-oriented code in the bits but they are "hidden" and not ready for you to use.
That isn't your real problem though. You'd get that error talking to any data service because your data request is cross-origin (that is, to a data server at a location other than http://run.plnkr.co) and the browser blocks cross-origin requests unless the server plays along. By that I mean the server supports CORS (or JSONP for request only scenarios).
We provide a public server that respects CORS. It currently delivers sample Todo data (http://sampleservice.breezejs.com/api/Todos/Todos) and Northwind data (http://sampleservice.breezejs.com/api/Northwind/employees) from SQL databases. You can see it at work in a jsFiddle with knockout (1) and in a plunker with angular.
Nothing for MongoDb just yet.
(1) StackOverFlow prevents me from giving you a link to jsFiddle. Silly, "nanny state" nonsense. So you'll have to construct the link for yourself from this: http://jsfiddle.net/" + "IdeaBlade/ExaFM/light/"
Update August 3, 2013
Released Node/Mongo support and a sample. See this SO question: What is the state of BreezeJS integration with express and mongo DB?
来源:https://stackoverflow.com/questions/16748401/angular-breeze-mongolab