AngularJS与MongoDB的连接 [英] AngularJS connection with MongoDB
本文介绍了AngularJS与MongoDB的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用角度制作了一个简单的HTML文件.我想将表单连接到MongoDB.
I have made one simple HTML file in angular. I want to connect my form to MongoDB.
我已经附加了"html文件"和"JS文件".
I have attached my "html file" and "JS File".
HTML文件
var app = angular.module('example',[]);
app.controller('TestController', function(){
$scope.user.name= "Hello";
$scope.user.mail = "test@gmail.com";
});
<html>
</!DOCTYPE html>
<html>
<head>
<title>TEST Page</title>
<!-- begin snippet: js hide: false console: true babel: false -->
</head>
<body ng-app="example" ng-controller="TestController">
<table>
<tr>
<td>Name:</td>
<td><input type="text" ng-model="user.name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" ng-model="user.mail"></td>
</tr>
<tr>
<td colspan="2"><button ng-click="getData()"></button></td>
</tr>
</table>
</body>
</html>
请帮助我......
Please help me......
推荐答案
如果使用-rest
参数启动mongod,则可以通过RESTful端点访问数据库集合,例如:
If you start mongod with the --rest
parameter you can access your DB collections via RESTful endpoints like:
http://ip:port/database/collection/?filter_name=filter_param
因此您可以发出AJAX请求并以JSON格式获取所需数据
So you can make a AJAX request and get the required data as JSON
有关更多详细信息,请参见 https://docs.mongodb.com/ecosystem/tools/http-interfaces/#rest-interfaces
For more details check the https://docs.mongodb.com/ecosystem/tools/http-interfaces/#rest-interfaces
这篇关于AngularJS与MongoDB的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文