我無法得到我的請求工作,即時通訊使用角度和即時通訊新的使用它,因爲我的項目規定我必須使用它,即時通訊試圖讓我的條目從我的mongodb batabase,即時通訊也運行expressjs服務器不適合所有的代碼,我可以請告訴我我的錯誤,我相信有很多。我不能得到我的請求工作
//factory
app.factory('whipmeet', ['$http', function($http) {
return $http.get('http://mongodb://127.0.0.1:27017/finalwhipmeet')
.success(function(data) {
return JSON.parse(data);
})
.error(function(err) {
return err;
});
}]);
//controller
app.controller('MainController', ['$scope', 'whipmeet', function($scope, whipmeet) {
whipmeet.success(function(data) {
$scope.meetinfo = data,
$scope.meetlikes = 23;
});
}]);
//index.html(only view)
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
</head>
<body ng-app="WhipMeetApp">
<h1><%= title %></h1>
<p>Welcome to <%= title %></p>
<h1 id="test1"> teting </h1>
<div class="main" ng-controller="MainController">
<div class="container">
<div class="card" ng-repeat="meet in meets">
<meet-info info="likes"></meet-info>
</div>
</div>
</div>
<!-- modules -->
<script src="/javascripts/app.js"></script>
<!-- controllers -->
<script src="/javascripts/controllers/MainController.js"></script>
<!-- services -->
<script src="/javascripts/services/whipmeet.js"></script>
<!-- directives -->
<script src="/javascripts/directives/meetInfo.js"></script>
</body>
</html>
//schema im trying to pull
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var MeetSchema = new Schema ({
name: String,
location: String,
car: String,
date: Date,
time: Number,
type: String,
stock: Boolean
});
module.exports = mongoose.model('Meet', MeetSchema);
//error i get in console
angular.js:9734 GET http://mongodb//127.0.0.1:27017/finalwhipmeet net::ERR_NAME_NOT_RESOLVED
,請告訴我,如果我需要發佈更多文件/代碼,這是明確的,真是對不起這可能是出於格式,但我是一個新手,我盡我所能來設置此通過教程和codeacademy,我只需要能夠顯示我的數據,以及如何以相同的格式創建一篇文章。 我非常感謝任何想幫助的人的幫助,請不要在noob上苛刻。
//meets.js route
var express = require('express');
var router = express.Router();
var Meet = require('../models/Meet.js');
/* GET /meets listing. */
router.get('/', function(req, res, next) {
Meet.find(function (err, meets) {
if (err) return next(err);
res.json(meets);
});
});
/* POST /meets */
router.post('/', function(req, res, next) {
Meet.create(req.body, function (err, post) {
if (err) return next(err);
res.json(post);
});
});
/* GET /meets/id */
router.get('/:id', function(req, res, next) {
Meet.findById(req.params.id, function (err, post) {
if (err) return next(err);
res.json(post);
});
});
/* PUT /meets/:id */
router.put('/:id', function(req, res, next) {
Meet.findByIdAndUpdate(req.params.id, req.body, function (err, post) {
if (err) return next(err);
res.json(post);
});
});
/* DELETE /meets/:id */
router.delete('/:id', function(req, res, next) {
Meet.findByIdAndRemove(req.params.id, req.body, function (err, post) {
if (err) return next(err);
res.json(post);
});
});
module.exports = router;
這是一個錯誤的方法。你的角色工廠應該調用你的快速路由,這反過來應該與MongoDB的本地驅動程序或包裝與mongoDB交談。 –
請問你是如何送我一個例子代碼如何?我也有明確的要求,我現在要發佈他們 –
@TalhaAwan你能請發表一個小例子,說明如何完成這項工作嗎?預先感謝您 –