<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<!-- compiled css output -->
<link href="css/ionic.app.css" rel="stylesheet">
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ionic/js/angular/angular-resource.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="ionicApp" ng-controller="MainCtrl">
<ion-content padding="true">
<form ng-submit="newPost()">
<label>New Post:</label>
<textarea ng-model="postData.text"></textarea>
<button type="submit" class="button button-positive button-block">Create</button>
</form>
</ion-content>
</body>
</html>
<!-- java script -->
angular.module('ionicApp', ['ionic', 'ngResource'])
.factory('Post', function($resource) {
return $resource('/api/post/:id');
})
.controller('MainCtrl', function($scope, Post) {
// Get all posts
$scope.posts = Post.query();
// Our form data for creating a new post with ng-model
$scope.postData = {};
$scope.newPost = function() {
var post = new Post($scope.postData);
post.$save();
}
});
Try this
return $resource('http://localhost:8100/api/post/:id);
I did try this earlier too. But no luck.