Saturday 1 April 2017

use ng-repeat to display mongoose queries

I want to use angular to show the array I get from mongoose.find(). My approach

controller:

requests:function(req,res){
        corporate.find({request:false},function(err,corp){
            if(corp){
                console.log("yes");
                res.render('requests',{corp});
            }
        });

View:

<!DOCTYPE html>
<html lang="eng" ng-app = "">
<head>
    <meta charset = "UTF-8">
    <title>Business Requests</title>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<h1>hello</h1>
<div ng-init = <%="bus=corp"%>>
    <p ng-repeat = "c in bus">
        Name:  <br>
        Email: <br>
        type: <br>
    </p>
</div>
</body>
</html>

it shows just nothing at all but the header hello



via Mahmoud Youssef

No comments:

Post a Comment