I have created a factory in my project as follows,
app.factory('userFactory', userFactory);
function userFactory() {
var userInitialValueSettings = {
UserId: '',
FullName: '',
Location: '',
Phone: '',
Ext: '',
Fax: '',
Email: '',
IsExternalUser: false,
Password: '',
UserMustChangePassword: false,
PasswordNeverExpires: false
}
return {
userInitailValues: userInitialValueSettings
}
}
I used the userInitialValues object of the factory to initialize one of my scope object as given below.
$scope.user = userFactory.userInitailValues;
I used the properties of $scope.user as the models of some input textboxes. I have a clear button in my form. I need to clear the textboxes while clicking the clear button. So I hooked the following function in the clear button click.
$scope.cancelAddUserDialoge = function () {
$scope.user = userFactory.userInitailValues;
}
But the text fields are not getting cleared. What is the issue? Can anybody help me? If I use the following method in the clear button click and clear each model property individually then, the textboxes are getting cleared.
function ResetUserModel() {
$scope.user.UserId= '',
$scope.user.FullName = '',
$scope.user.Location = '',
$scope.user.Phone = '',
$scope.user.Ext = '',
$scope.user.Fax = ''
$scope.user.Email = '',
$scope.user.IsExternalUser = false,
$scope.user.Password = '',
$scope.user.UserMustChangePassword =false,
$scope.user.PasswordNeverExpires =false
}
Why I cannot use the factory object to clear the models? Please help me.