Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

TypeError: Cannot read property 'source' of undefined with custom templates #1597

Closed
katemihalikova opened this issue May 10, 2016 · 2 comments

Comments

@katemihalikova
Copy link
Contributor

Bug description:

When the ui-select is being rendered, error is shown in console:

TypeError: Cannot read property 'source' of undefined
    at Array.<anonymous> (select.js:1840)
    at ngModelWatch (angular.js:26943)
    at Scope.$digest (angular.js:17064)
    at Scope.$apply (angular.js:17337)
    at done (angular.js:11572)
    at completeRequest (angular.js:11778)
    at XMLHttpRequest.requestLoaded (angular.js:11711)

This happens only when using custom templates that need to be fetched.
Seems related to #1440.

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/Xk6lyhMoqWRAhDg7IK6h?p=preview

Version of Angular, UI-Select, and Bootstrap/Select2/Selectize CSS

Angular 1.5.5
UI-Select 0.16.1
Any CSS

@user378230
Copy link
Contributor

user378230 commented May 13, 2016

This might be as simple as checking for parserResult is there before trying to access the source property.

uiSelectSingleDirective.js#L21

eg:

var data,
  locals = {},
  result;
  if($select.parserResult && $select.parserResult.source) {
    data = $select.parserResult.source(scope, { $select : {search:''}}); //Overwrite $search
  }
  if(data) {
    ..

I'm not sure if this would affect anything else...

Can you submit a PR?

@katemihalikova
Copy link
Contributor Author

Will do, thanks for investigation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants