-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Issue: TypeError: Cannot read property 'length' of undefined at ctrl.getPlaceholder #519
Comments
Wer you able to resolve this? I am stuck with exactly the same issue. |
No I wasn't unfortunately.
|
I was having this issue earlier and managed to fix it. Your ng-model is a list that the select is pushing to... so it should be something like selectedLanguages and then in your controller create $scope.selectedLanguages = []. When you need to retrieve the data you can create an object with curriculum.languages: $scope.selectedLanguages. Hope that helps! |
Thanks a lot for your input Natalie. :-) Can you please explain what you think the issue has got to do? My Regards, Julien. |
+1 |
+1. Its happening in the watch of At line 312: we have |
Figured out the repeater error / 'Can't Interpolate bug' / getPlaceholder. |
Just to add to this, in my case i get the dropdown list async, so initially we need to define |
To elaborate on skchi's very helpful answer, I ended up needing to instantiate my objects at the very top of the directive (in my case). I have a function for grabbing the data I use to populate the select box and I was declaring my 'scope.users.selected = [];' within that function. Once I moved that declaration outside the function and to the top of the link section, the length errors were gone. Hope that helps! |
@natalie03 thanks! This solved my issue. |
@justsml Have you noticed that your solution omits an actual Placeholder from being rendered? |
My bad. Removing the role displays the placeholder. |
Same problem here. Making sure ng-model is bound to an initialized array worked-around for me too. (per @skchi and @NateVonSmith) |
@newbyca : Ditto. And to spell it out for everyone else
|
skchi's solution is correct. |
@skchi, thank you very much! :) |
@natalie03 thanks a lot!!! Your suggestion ("in your controller create $scope.selectedLanguages = []") it solved all of my problems :) |
@natalie03 nice find this is a real gotcha if you're not careful with ui-select |
I use the latest version of Angular ui select and I get the following error:
TypeError: Cannot read property 'length' of undefined
at ctrl.getPlaceholder (http://localhost:8080/bower_components/angular-ui-select/dist/select.js:507:40)
at $parseFunctionCall (http://localhost:8080/bower_components/angular/angular.js:12299:18)
at Object.expressionInputWatch (http://localhost:8080/bower_components/angular/angular.js:12702:31)
at Scope.$digest (http://localhost:8080/bower_components/angular/angular.js:14187:40)
at Scope.$apply (http://localhost:8080/bower_components/angular/angular.js:14457:24)
at http://localhost:8080/bower_components/angular/angular.js:16183:36
at completeOutstandingRequest (http://localhost:8080/bower_components/angular/angular.js:4889:10)
at http://localhost:8080/bower_components/angular/angular.js:5269:7
Here is my markup:
I am not sure if this is a bug or if I am getting something wrong...
The text was updated successfully, but these errors were encountered: