Skip to content

TypeError: Cannot read property 'length' of null #44

@rbecheras

Description

@rbecheras

TypeError: Cannot read property 'length' of null
at Object.fn (angularjs-color-picker.js:155)
at Scope.$digest (angular.js:14394)
at Scope.$apply (angular.js:14657)
at done (angular.js:9734)
at completeRequest (angular.js:9924)
at XMLHttpRequest.requestLoaded (angular.js:9865)(anonymous function) @ angular.js:11707(anonymous function) @ angular.js:8628Scope.$digest @ angular.js:14412Scope.$apply @ angular.js:14657done @ angular.js:9734completeRequest @ angular.js:9924requestLoaded @ angular.js:9865

In the code:

$scope.$watch('ngModel', function (newValue, oldValue) {
  if (newValue !== undefined && newValue !== oldValue && newValue.length > 4) {
    ...
  }
}

Needs to be replaced by the following snippet to not crash for null value of the model:

$scope.$watch('ngModel', function (newValue, oldValue) {
  if (newValue !== undefined && newValue !== null && newValue !== oldValue && newValue.length > 4) {
    ...
  }
}

I will make a pull request

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions