I encountered an issue with the following error message: TypeError: MyTheme.register is not a function
This error occurred when I tried to invoke this function from my package in the controllers folder. I attempted the following:
vm.register = function() {
MyTheme.register(this.user);
};
I also tried this approach:
vm.register = function() {
MyTheme.prototype.register(this.user);
};
Unfortunately, both of my attempts were unsuccessful.
The function can be found in my package at services/myTheme.js:
'use strict';
angular.module('mean.myTheme').factory('MyTheme', [
function() {
MeanUserKlass.prototype.register = function(user) {
$http.post('/api/register', {
email: user.email,
password: user.password,
confirmPassword: user.confirmPassword,
username: user.username,
name: user.name
})
.success(this.onIdentity.bind(this))
.error(this.onIdFail.bind(this));
};
return {
name: 'myTheme'
};
}
]);