Saturday, 15 January 2011

total.js - POST request in Angularjs -



total.js - POST request in Angularjs -

i'm new totaljs. wrote code seek create user set request angular factory:

app.factory('user', function($resource) { homecoming $resource('/register', null, { register: { method: 'post' } }); });

in angular controller, when click on register button method run:

$scope.register = function() { $scope.user = new user({email: $scope.email, password: $scope.password}); $scope.user.$register(); }

after click on register button, in console got :

failed load resource: network connection lost.

this totaljs controller:

exports.install = function(framework) { framework.route('/register', registerpage); framework.route('/register/', register, ['post']); }; function registerpage() { var self = this; self.view('registerpage') } function register() { var self = this; console.log("run") // instead add together new user homecoming existing user test var user = model('user').schema user.find(function(err, docs) { self.json(docs); }); }

when seek jquery's $.ajax works fine! problem? thanks

i inquire question peter Širka, mail service answer:

hello, it's ok. found problem in route:

framework.route('/register', register, ['put', 'json']);

angularjs total.js

No comments:

Post a Comment