Material: md-select mapFn undefined

Created on 9 Dec 2015  路  15Comments  路  Source: angular/material

In some cases the mapFn variable is undefined. This leads to errors like:

TypeError: undefined is not a function
    at Array.map (native)
    at Object.SelectMenuController.self.selectedLabels (http://localhost:9001/vendor/js/angular-material/angular-material.js:13780:34)
    at Scope.$digest (http://localhost:9001/vendor/js/angular/angular.js:15888:40)
    at Scope.$apply (http://localhost:9001/vendor/js/angular/angular.js:16160:24)
    at HTMLElement.clickListener (http://localhost:9001/vendor/js/angular-material/angular-material.js:13648:13)
    at HTMLElement.jQuery.event.dispatch (http://localhost:9001/vendor/js/jquery/jquery.js:4435:9)
    at HTMLElement.elemData.handle (http://localhost:9001/vendor/js/jquery/jquery.js:4121:28)

It appears to be caused by https://github.com/angular/material/commit/f73e5033bd4446412ca6b5ce7a769901274f4147#diff-d7b463f733c2e3fbc783f38073561b74R632 when mode is equal to display

urgent

Most helpful comment

It appears the opts in self.selectedLabels = function(opts) { sometimes has the controller scope in it's prototype so opts.mode is equal to $scope.mode.

A temporary workaround for this would be not to use mode in scope.

All 15 comments

yeah i have some issue like this , hopefully to be fixed

Same here, need to be fixed

I have the same problem

Same here, any clues ?

It appears the opts in self.selectedLabels = function(opts) { sometimes has the controller scope in it's prototype so opts.mode is equal to $scope.mode.

A temporary workaround for this would be not to use mode in scope.

Same issue, needs to be fixed.

Right solution by @suur confirmed working, thanks a lot!

Please patch this bug !!

solution is don't use $scope.mode change to another name

Thank you.
It works when avoid using $scope.mode principaly in a whole app controller.
However a patch will be welcome

+1 same issue here

replace scope.$watch(selectMenuCtrl.selectedLabels, syncLabelText);
with:

scope.$watch(function() { // replaced
        return selectMenuCtrl.selectedLabels();
      }, syncLabelText); 

+1 spend lots of time to find root cause.

Had $scope.mode in my controller. Thanks suur for your help. Waiting for better incapsulation...

This is a duplicate of #6260, which already has a PR pending - #7830.

I will close that issue, because the other issue, is already referenced by the PR.

Was this page helpful?
0 / 5 - 0 ratings