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

Undefined is not a function - inexplicable error #555

Closed
turbobuilt opened this issue Dec 29, 2014 · 8 comments
Closed

Undefined is not a function - inexplicable error #555

turbobuilt opened this issue Dec 29, 2014 · 8 comments

Comments

@turbobuilt
Copy link

Hello,

I'm working with version 0.9.4 and AngularJS 1.3.5. I have an issue that doesn't usually cause any problem, but nevertheless shows up as an error in the console.

I have pretty much standard code - I'm trying to get a basic dropdown to function in a dead-simple scenario, so I can use it for more. Here, where $scope.genders is an arrray: ['male','female'], I'm trying to make a super simple select with just these two options. The great thing is that it almost always works as it should. The problem is that it also throws two errors I just can't figure out that I think sometimes cause it to malfunction (maybe 1 in 20 times). Since it mostly works, I'm wondering if this is an error with compatibility with angular 1.3.5 or something like that. Here is my code, and then the error. Help very much appreciated. Using Select2 theme.

<ui-select ng-model="formData.gender" ng-disabled="disabled">
                    <ui-select-match placeholder="Gender">{{$select.selected}}</ui-select-match>
                    <ui-select-choices repeat="genderOption in genders | filter: $select.search">
                        <div>
                            <span class="h1">{{genderOption}}</span>
                        </div>
                    </ui-select-choices>
                </ui-select>

And the errors:

TypeError: undefined is not a function at Function.$$addBindingInfo (http://localhost:1112/js/angular.js:6800:18) at ngBindHtmlLink (http://localhost:1112/js/angular.js:21922:18) at invokeLinkFn (http://localhost:1112/js/angular.js:8141:9) at nodeLinkFn (http://localhost:1112/js/angular.js:7653:11) at compositeLinkFn (http://localhost:1112/js/angular.js:7009:13) at nodeLinkFn (http://localhost:1112/js/angular.js:7648:24) at compositeLinkFn (http://localhost:1112/js/angular.js:7009:13) at nodeLinkFn (http://localhost:1112/js/angular.js:7648:24) at delayedNodeLinkFn (http://localhost:1112/js/angular.js:7902:11) at compositeLinkFn (http://localhost:1112/js/angular.js:7009:13) <div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label ng-binding" ng-bind-html="$group.name"> angular.js:11500 TypeError: undefined is not a function at Function.$$addBindingInfo (http://localhost:1112/js/angular.js:6800:18) at ngBindHtmlLink (http://localhost:1112/js/angular.js:21922:18) at invokeLinkFn (http://localhost:1112/js/angular.js:8141:9) at nodeLinkFn (http://localhost:1112/js/angular.js:7653:11) at compositeLinkFn (http://localhost:1112/js/angular.js:7009:13) at nodeLinkFn (http://localhost:1112/js/angular.js:7648:24) at compositeLinkFn (http://localhost:1112/js/angular.js:7009:13) at compositeLinkFn (http://localhost:1112/js/angular.js:7012:13) at publicLinkFn (http://localhost:1112/js/angular.js:6888:30) at link (http://localhost:1112/js/select.js:1235:42) <div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label ng-binding" ng-bind-html="$group.name">

@Arkh1
Copy link

Arkh1 commented Jan 1, 2015

I am getting this same error and posted it a while back. Glad to see I am not the only one.

#517

In Firefox it shows up as "Error: c.push is not a function"

I should add that I have not found a solution to the issue yet. Working on debugging it right now actually.

@Arkh1
Copy link

Arkh1 commented Jan 5, 2015

No luck so far... Anybody have any ideas?

@Arkh1
Copy link

Arkh1 commented Jan 16, 2015

So I've got a workaround in the interest of not flooding the logs with error messages. The errors are caused by the ng-bind-html attributes used in ui-select. Replace the three instances in the ui-select.js with standard {{}} syntax and replace the ui-select instances of ng-bind-html in your views with the same {{}} syntax. After doing that you shouldn't see the error any more.

I imagine there is a more appropriate fix and the bug leads me to believe that it has something to do with the ngSanitize, but I'm not going to be taking the time to look into it beyond the temporary fix that I have.

I should also mention that if you are actually using html in the bindings you will have to find a different solution.

@turbobuilt
Copy link
Author

Awesome, thanks for the fix @Arkh1. That fixed it for me.

@btm1
Copy link

btm1 commented Jan 27, 2015

I'm having this issue and I am using html so this fix won't work for me :( i'll need to figure something else out

@Arkh1
Copy link

Arkh1 commented Jan 28, 2015

If you want to look into an actual fix I imagine this is a good place to start.
angular/angular.js@dae6947

As part of the 1.3 upgrade ng-bind-html was brought into the core of angular. The above link is the changeset to reflect that modification.

@darmie
Copy link

darmie commented Jun 6, 2015

Anyone fixed this issue yet?

@wesleycho
Copy link
Contributor

Going to close as this is confusing and needs more information - feel free to open a new issue with appropriate reproduction in Plunker based on the latest release.

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

No branches or pull requests

5 participants