Answer the question
In order to leave comments, you need to log in
TypeError: object is not a function what does she climb finally what does she want from me?
angular
.module('starter', [])
.controller('UserCtrl', ['$scope', 'User', function($scope, User) {
$scope.regInfo = {};
$scope.insert = function(){
User = new User ();
User.insert ($scope.regInfo);
}
}])
.factory('User', ['$http', function($http) {
function User(UserData) {
if (UserData) {
this.setData(UserData);
}
};
User.prototype = {
setData: function(UserData) {
angular.extend(this, UserData);
},
insert: function(regInfo){
$http({method: 'GET', url: 'http://car.bleg.ru/api.php?class=get_session&method=register&car_name='+regInfo.carwash_name+'&car_average_check='+regInfo.car_average_check+'&car_address='+regInfo.car_address+'&car_tags='+regInfo.car_tags+'&car_st_time='+regInfo.car_st_time+'&carwash_cl_time='+regInfo.car_cl_time+'&carwash_pos='+regInfo.car_pos+'&email='+regInfo.email+'&passwd='+regInfo.passwd+'&passwd2='+regInfo.passwd2})
.success(function(data, status, headers, config) {
alert(data);
})
.error(function(data, status) {
alert('ошибка епте');
});
}
};
return User;
}]);
Answer the question
In order to leave comments, you need to log in
You return a function in a factory, and this can only be done in a service. In a factry, only an object can be returned. That is, replace .factory('User' with .service('User' or vene an object rather than a function that becomes a class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question