Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your job is to add a due date text box to the application and save it to the MongoDB. A screenshot of the completed project

Your job is to add a due date text box to the application and save it to the MongoDB. A screenshot of the completed project should look like this:

If you use Mongo Shell you can see the data are saved in the database:

Here are the settings of the database:

Database URL: mongodb://127.0.0.1:27017/local

Database name: local(You can deduce from the above URL.)

Collection name: items

Document format: {details: shopping for swimsuits, duedate: 08/01/2016}

Hint:

You need to download MongoDB and install it locally on your machine.

You need to make sure you have a folder C:\data\dbcreated. This is the default location where all MongoDBs data files are saved.

You need to create the collection named feedback through Mongo shell commands:

use local

You only need to change main.js and index.html files.

You only need to submit the modified main.jsand index.htmlfiles.

======

MAIN.JS

========

var demoApp = angular.module('demo', []); demoApp.controller('MainController', ['$scope', 'todoWebService', function ($scope, todoWebService) {

// Setup a view model var vm = {};

vm.list = [];

// Start the initial load of lists todoWebService.getItems().then(function (response) { vm.list = response.data.items; });

vm.addItem = function () { var item = { details: vm.newItemDetails };

// Clear it from the UI vm.newItemDetails = '';

// Send the request to the server and add the item once done todoWebService.addItem(item).then(function (response) { vm.list.push({ _id: response.data.itemId, details: item.details }); }); };

vm.removeItem = function (itemToRemove) { // Remove it from the list and send the server request vm.list = vm.list.filter(function (item) { return item._id !== itemToRemove._id; }); todoWebService.removeItem(itemToRemove); };

// For new items: vm.newItemDetails = '';

// expose the vm using the $scope $scope.vm = vm; }]);

demoApp.service('todoWebService', ['$http', function ($http) { var root = '/todo'; return { getItems: function () { return $http.get(root); }, addItem: function (item) { return $http.post(root, item); }, removeItem: function (item) { return $http.delete(root + '/' + item._id); } } }]);

====

Index.html

Sample App

List

{{item.details}}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions