학교 프로젝트에 도움이 필요합니다. Im은 해결해야 할 문제 목록을 만들고 업데이트하기위한 앱을 만듭니다.MEAN을 사용하여 데이터 저장
나는이 문제를 삽입하기로되어있는 입력란을 가지고 있으며 ID, "Open"상태 및 datestamp를 생성해야합니다.
그러면 내 출력 테이블에 문제가 표시됩니다. 나는 databas에서 무엇을 표시 할 수 있는지를 해결했다. 이제는 새로운 데이터를 저장하는 부분을 해결해야합니다.
제 계획은 AddIssue 버튼에 ng-click을 사용하고 AddIssue라고하는 함수를 호출하는 것입니다. 그런 다음 데이터 저점을 전송하고 데이터
HTML
<div ng-controller="inputCtrl">
<p>New issue <input class="form-control" type="text" ng-model="newIssue"></p>
<button ng-click="AddIssue()"> Add </button>
</div>
<div ng-controller="tableCtrl">
<table class="table table-striped">
<thead>
<tr>
<th>Status</th>
<th>Issue</th>
<th>Date</th>
<th>ID</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="issue in issueList">
<td>{{issue.status}}</td>
<td>{{issue.issue}}</td>
<td>{{issue.date}}</td>
<td>{{issue.id}}</td>
</tr>
</tbody>
</table>
</div>
내 JS 파일 controller.js
var myApp = angular.module('myApp', []);
// Controller for input
myApp.controller('inputCtrl', function($scope) {
// Call function when click on AddIssue btn
$scope.AddIssue = function() {
console.log("Click click....")
// Use Post to send data to database
$http.post('/issueList').sucess(function(response){
$scope.newIssue = 'New issue';
})
}
}); // End of input
서버를 저장하는 moongose를 사용하여 $의 HTTP 포스트를 사용하여. js
/* Connect to db issues */
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/issues');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
/* Connect to MongoDB */
db.once('open', function (callback) {
console.log("Connected to db");
// Created b-schema
issueSchema = mongoose.Schema({
id: String,
issue: String,
date: String,
status: String
});
// Create Model
Issue = mongoose.model('Issue', issueSchema);
이 지금까지 내가 온 것을, 그리고 지금은 내 MongoDB를이
:
은 한 번보세요. 이것은 MEAN 스택을 사용하여 할 일 목록을 만드는 방법에 대한 멋진 기사입니다. https://scotch.io/tutorials/creating-a-single-page-todo-app-with-node-and-angular. –