简体   繁体   中英

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. 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. I am new to MEAN stack so please spare me.

Please go through video tutorial of Bucky Robert. Try to create the project from Hello world then you will understand.

Node JS tutorial click here

MEAN STACK tutorial: click here

First Create RestFul API using Node js 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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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