My index.html file in ionic looks as follows...
<ion-content>
<form name="login" method="post" action="/">
<div class="list list-inset">
<label class="item item-input">
<input type="text" placeholder="First Name">
</label>
<label class="item item-input">
<input type="text" placeholder="Last Name">
</label>
<input type="submit" value="Submit">
</div>
</form>
</ion-content>
Its a simple form, that's all. But when submit is clicked I want to be able to catch the request using node.js.
I have a separate server file with the following in it...
var express = require('express');
var app = express();
app.post('/', function (req, res) {
console.log("post worked");
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
In Ionic, in my angular app.js I am trying to connect to this node.js server file...
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
.factory('Session', function ($resource) {
return $resource('http://XXX.XXX.X.XX:3000/sessions/:sessionId');
});
But I do not think the connect is working. I'm using my private IP to connect. How can I get this to work? Also, how do I know if node.js is picking up the request? Where will console.log("post worked") print to?
EDIT
I changed my angular module to Mini Bhati's answer...
angular.module('starter',['ionic','ngResource']);
but I still cannot get the POST request
/router where you want to listening in server side?