I'm new to Totaljs. I wrote a code which try to create user with PUT request with angular factory:
app.factory('User', function($resource) {
return $resource('/register', null, {
register: { method: 'post' }
});
});
In my angular controller, when I click on register button this 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 I got this :
Failed to load resource: The network connection was lost.
This is my 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 new user I just return an existing user for test
var User = MODEL('user').Schema
User.find(function(err, docs) {
self.json(docs);
});
}
When I try it with jQuery's $.ajax It works fine! So what is the problem? Thanks