Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ { _id: 5880e3a737893c04c87e30bf,
- name: 'Tom',
- email: 'Tom@msn.com',
- number: '4444444444' },
- { _id: 5880e44637893c04c87e30c0,
- name: 'Tracy',
- email: 'Tracy@asodj.com',
- number: '123412345' },
- { _id: 5880e44637893c04c87e30c1,
- name: 'tucker',
- email: 'tucker@email.com',
- number: '1234456666' } ]
- var express = require('express');
- var app = express();
- var mongojs = require('mongojs');
- var db = mongojs('contactlist', ['contactlist']);
- app.use(express.static(__dirname + "/public"));
- app.get('/contactlist', function(req, res){
- db.contactlist.find(function (err, docs) {
- console.log(docs);
- res.json(docs);
- });
- });
- app.listen(3000);
- console.log("Server running on port 3000");
- var myApp = angular.module('myApp', []);
- myApp.controller('AppCtrl', ['$scope', '$http', function($scope, $http) {
- $http.get('/contactlist').success(function(response){
- console.log("I got the data i requested");
- $scope.contactlist = response.data;
- });
- }]);
- <!DOCTYPE html>
- <html ng-app="myApp">
- <head>
- <title>Contact List App</title>
- <!-- Latest compiled and minified CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <!-- Optional theme -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
- </head>
- <body>
- <div class="containter" ng-controller="AppCtrl">
- <h1>Contact List App</h1>
- <table class="table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th>Number</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="contact in contactlist">
- <td>{{contact.name}}</td>
- <td>{{contact.email}}</td>
- <td>{{contact.number}}</td>
- </tr>
- </tbody>
- </table>
- </div>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
- <script src="controllers/controller.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement