javascript - How to display the contents of mongo db in front end? -


i working on meanstack , new it. requirement want contents of mongo db displayed on web page. believe done using angular js. have created module named 'display' along angular modules of mean stack server, client , test folders inside it. in config folder of client, there 2 files, users.client.menus.js , users.client.routes.js

the following users.client.menus.js,

(function () {   'use strict';    angular     .module('display')     .run(menuconfig);    menuconfig.$inject = ['menuservice'];    function menuconfig(menuservice) {   menuservice.addmenuitem('topbar',{       title: 'display table',       state: 'display',       type:'label',       roles: ['*']     });   }   }()); 

users.client.routes.js

(function () {   'use strict';     angular     .module('display.routes')     .config(routeconfig);      routeconfig.$inject = ['$stateprovider'];     function routeconfig($stateprovider) {     $stateprovider     .state('display',{         url: '/display',         templateurl: 'modules/display/client/views/display.client.view.html',         controller: 'displaycontroller',         controlleras: 'vm',         data: {             roles: ['user','admin'],             pagetitle: 'display'         }     });      }    }()); 

the controller file follows: display.client.controller

(function () {   'use strict';    angular     .module('display')     .controller('displaycontroller', displaycontroller);      displaycontroller.$inject = ['$scope', 'displays','authentication'];      function displaycontroller($scope,displays,authentication) {       $scope.authentication = authentication;       var vm = this;       vm.displays = displays;     }    }()); 

display.client.view.html

<section data-ng-controller="displaycontroller">     <div class="page-header">      <h1>display</h1>   </div> <form class="col-xs-12 col-md-offset-4 col-md-4">     <fieldset class="row">         <div class="panel panel-default" data-ng-init="find()">             <table class="table table-hover table stripped">                 <thead>                     <tr>                         <th>details</th>                     </tr>                 </thead>                 <tbody>                     <tr data-ng-repeat="displaynames in testdata" data-ng-href="#!/display/{{displaynames.displayname}}">                         <h4 data-ng-bind="displaynames.displayname"></h4>                         <td>{{displaynames.displayname}}</td>                     </tr>                 </tbody>             </table>         </div>       </fieldset> </form>   </section> 

in server, have models folder, display.server.model.js

'use strict';  var mongoose = require('mongoose'),     schema = mongoose.schema; var user = new mongoose.schema({     displayname:{         type: string,         default:''     },     username:{         type: string,         default:'',         unique: true,         required:'username cannot empty'     },     email:{         type: string,         default:'',         unique: true,         required:'email cannot empty'     },     user:{         type: schema.objectid,         ref: 'user'     }  });  mongoose.model('display',user); 

i want know additional folders required complete task , how can accomplish requirement.

thanks, in advance.

for accessing data database need server , apis running on server data database , send response on frontend native client server architecture. data database need write apis , if writing code in javascript need nodejs application have interaction database. can read this article on how make rest apis , make use of them on frontend angularjs application. happy learning. cheers:)


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -