CRUD Code Using Mongoose MEAN Stack
CRUD Code Using Mongoose MEAN Stack
js (ExpressJS file)
mongoose.connect("mongodb://0.0.0.0:27017/admin")
var conn = mongoose.connection
conn.on('connected',function(){
console.log("Connected to mongoDB")
})
})
app.listen(1000,function(){
console.log("Express server is running on port 1000")
})
angular.module('myApp', [])
.controller('myController', function ($scope, $http) {
$scope.items = [];
$scope.stat=0
$scope.errorMsg={}
// Function to get all items from the server
$scope.getItems = function () {
$http.get('/api/items').then(function (response) {
$scope.items = response.data;
});
};
});
};