简体   繁体   English

从mongodb检索nodejs-angular数据

[英]nodejs-angular retrieving data from mongodb

I have been trying to retrieve data from mongodb (i'm using also mongoose) and send it to angular to fill the ng-repeat list with data. 我一直在尝试从mongodb检索数据(我也使用猫鼬),并将其发送到angular以用数据填充ng-repeat列表。 I am able to print data on blank page from mongo OR display data in list if i declare exemplary static array with data in a list on webpage but i dont know how to connect it to work with data from mongo. 如果我用网页列表中的数据声明示例静态数组,我可以从mongo的空白页上打印数据或在列表中显示数据,但是我不知道如何连接它以使用mongo的数据。 I am new to MEAN stack so please spare me. 我是MEAN Stack的新手,所以请饶恕我。

Please go through video tutorial of Bucky Robert. 请浏览Bucky Robert的视频教程。 Try to create the project from Hello world then you will understand. 尝试从Hello world创建项目,您将了解。

Node JS tutorial click here Node JS教程请点击这里

MEAN STACK tutorial: click here MEAN STACK教程: 单击此处

First Create RestFul API using Node js http://adrianmejia.com/blog/2014/10/01/creating-a-restful-api-tutorial-with-nodejs-and-mongodb/ 首先使用Node js创建RestFul API http://adrianmejia.com/blog/2014/10/01/creating-a-restful-api-tutorial-with-nodejs-and-mongodb/

Then consume the same using following example. 然后使用以下示例使用相同的内容。

MessageServiceData.getMessageService=function(){
        var def = $q.defer();
                $http.post("www.url.com", data)
                    .success(function(messages){
                         def.resolve(messages);
                     })
                    .error(function(messagesFail){
                        console.log('error:'+JSON.stringify(messagesFail));
                        def.reject([{"Error":JSON.stringify(messagesFail)}]);
                    });

        return def.promise;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM