-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I'm using AngularJS v1.3.15 and I've included following on my html document
<script src="~/App/angular-validator.js"></script>
<script src="~/App/angular-validator-rules.js"></script>
This is what's in there in App.js
angular.module('App ', [
'ui.router',
'ngAnimate',
'validator', 'validator.rules',
'User'
]).config(['$validatorProvider', function ($validatorProvider) {
$validatorProvider.register('requiredSubmit', {
validator: /^.+$/,
error: 'This field is required.'
});
$validatorProvider.register('requiredBlur', {
invoke: 'blur',
validator: /^.+$/,
error: 'This field is required.'
});
$validatorProvider.register('numberSubmit', {
validator: /^[-+]?[0-9]*[\.]?[0-9]*$/,
error: 'This field should be number.'
});
}]).run(function ($validator) {
return $validator.register('requiredRun', {
invoke: 'watch',
validator: /^.+$/,
error: 'This field is requrired.'
});
});
This is what i've on User.js
angular
.module('User.Account', ['ngSanitize', 'ui.bootstrap', 'dialogs.main', 'ui.router'])
.controller('Account', Account);
Account.$inject = ['$scope', '$rootScope', '$timeout', '$state', '$location', '$http', '$log', '$sce', 'dialogs', 'logger', '$validator', 'deserializer', 'AccountService'];
function Account($scope, $validator ) {
$scope.formWatch = {
required: '',
regexp: '',
requiredRun: '',
number: 100,
number2: '',
http: ''
};
$scope.formSubmit = {
required: '',
regexp: '',
number: '',
http: '',
submit: function () {
return $validator.validate($scope, 'formSubmit').success(function () {
return console.log('success');
}).error(function () {
return console.log('error');
}).then(function () {
return console.log('then');
});
},
reset: function () {
return $validator.reset($scope, 'formSubmit');
}
};
}
When i run the project, it gives me following error
TypeError: Cannot read property 'init' of null
at angular-validator.js:143
typeof rule.init // shows undefined
if (typeof rule.init === "function") {
rule.init(scope, element, attrs, $injector);
}
Please let me know if i'm missing something. I would appreciate any help.
Thanks,
Amit
Metadata
Metadata
Assignees
Labels
No labels