codeigniter - How do I post data using $resource using angularjs -


i'm having bit of problem, i'm trying http post request backend php. i'm new angular , wanted try different rest method. i'm method. after try update , delete method i'm stuck on this. t__t.

here bit of code in php

$data = array(         "email" => $email,         "password" => $this->input->post("password")     ); $insert_data = $this->player_registration->insert($data); 

and here factory

angular.module('myapp.services', ['ngresource']) .factory('webservice', function($resource){ var apiurl = "http:domain.com/feed/"; //change web service var factory = {};  factory.registerplayer = function() {     return $resource( apiurl + ':type', {type:'player'}, {         post: {method:'post', params: {}}     }); };  factory.getplayerbyemail = function () {     return $resource( apiurl + ':type', {type:'player'}, {         get: {method: "get", params: {}}     }); }; return factory; }) 

and controller

function registercontroller($scope, webservice) { $scope.inputs = {}; $scope.inputs.email = "testuser@domain.com"; $scope.inputs.password = "password";  var req = new webservice.registerplayer($scope.inputs); req.save() 

my app.js

angular.module('myapp', ['myapp.filters', 'myapp.services', 'myapp.directives', 'myapp.controllers']) 

the default save() in $resources $save().

var req = new webservice.registerplayer($scope.inputs); req.$save() 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo