這裏是fiddle參考破碎的代碼。當我嘗試它時,它應該發送給它的服務器沒有響應,這導致我相信它沒有收到來自我的應用程序的任何流量。問題是否明顯?如果不是,我可以使用哪些故障排除方法來調查問題?爲什麼不是我的函數發送POST
stackoverflow希望我包含我的代碼內聯所以這裏它是。
index.html
<div ng-controller="DataEntryCtrl">
<form ng-repeat="entryField in entryFields">
<input type="text"
ng-model="entryField.fieldData"
placeholder="{{entryField.pHolder}}">
</form>
<input type="button" ng-click="sendJSON()" value="Object To JSON" />
<hr/>
{{res}}
<ul>
<li>ID: {{entryFields.id.fieldData}}</li>
<li>description: {{entryFields.description.fieldData}}</li>
<li>date: {{entryFields.date.fieldData}}</li>
</ul>
</div>
controller.js
'use strict';
/* Controllers */
var app = angular.module('Hubbub-FrontEnd', ['ngResource']);
app.controller('DataEntryCtrl', function($scope,$resource) {
$scope.entryFields = {
id: {pHolder:'ID goes here',fieldData:""},
description: {pHolder:'Description goes here',fieldData:""},
date: {pHolder:'Drop Dead Date goes here',fieldData:""}
};
$scope.showJSON = function() {
$scope.json = angular.toJson($scope.entryFields);
};
$scope.sendJSON = function() {
$scope.entry = angular.toJson($scope.entryFields);
$scope.res = $resource('http://10.64.16.6:3000/Create',
{create:{method:'POST'}},{params:$scope.entry});
};
});
好問題,但是標題缺少「angularjs」。 – Wiseman