material icon indicating copy to clipboard operation
material copied to clipboard

Error: [Ara Error] [$compile:ctreq] Controller 'mdSelectMenu', required by directive 'mdOption', can't be found!

Open mohsinmuzawar opened this issue 10 years ago • 25 comments

Error: [Ara Error] [$compile:ctreq] Controller 'mdSelectMenu', required by directive 'mdOption', can't be found!

this happens when i open md-dialog which has md-select which is populated by getting data through a http request and when i close and try to open md-dialog again it throws this error

mohsinmuzawar avatar Jan 23 '16 11:01 mohsinmuzawar

+1

jeson114 avatar Jan 27 '16 07:01 jeson114

Please provide a CodePen or Plunkr that demonstrates this issue. Here are some starter demo templates that you can use/fork:

  • CodePen template: http://codepen.io/pen?template=bEGJdd
  • Plunkr template: http://plnkr.co/edit/yP0gB9iTacIQb48thud8?p=preview.

ThomasBurleson avatar Jan 27 '16 17:01 ThomasBurleson

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

i created this plunker to demo my problem but it works fine over here. I dont knw wats going with it.

mohsinmuzawar avatar Jan 28 '16 06:01 mohsinmuzawar

I am having the same issue too.

KalpanaAr avatar Feb 10 '16 21:02 KalpanaAr

The same problem, but occurs only sometimes.

The code: md-input-container.language-select md-select(md-no-ink, ng-model="language") md-option(ng-value="key" ng-repeat="(key, lang) in languages") {{ lang.name }}

R-Kurbatovvakoms avatar Feb 17 '16 15:02 R-Kurbatovvakoms

I found that I had this issue due a digest call on the scope that should not have append. In my case a state.go from UI router.

hthetiot avatar Feb 23 '16 20:02 hthetiot

@hthetiot and how did you fix that?

R-Kurbatovvakoms avatar Feb 25 '16 10:02 R-Kurbatovvakoms

@hthetiot I would like to know as well.

soohoowoohoo avatar Mar 07 '16 21:03 soohoowoohoo

Same issue here.

Only happens in the second time that I open the dialog.

cleever avatar Mar 08 '16 15:03 cleever

I can't reproduce the issue with @mohsinmuzawar's demo. Is there a demo, which shows the issue? Or am I missing something?

devversion avatar Mar 08 '16 17:03 devversion

@DevVersion I Cant reproduce it on plunker or codepen and it only occurs when u open the dialog second time

mohsinmuzawar avatar Mar 08 '16 17:03 mohsinmuzawar

@mohsinmuzawar I can't investigate if I don't have stuff to work on. So a screenshot / GIF or anything else would be good.

devversion avatar Mar 08 '16 17:03 devversion

I've found my fix! (hopefully this can help more of you out there).

Note: Using Angular-UI-Router

The way I fixed my issue was by including the templateUrl property in my view object. In the screenshot I've provided below, I was getting the issue in my 'role_assign' view but I wasn't getting an issue for my 'chat_board_view'. In my parent template I was declaring the role_assign view and including the html in the parent template and only defining the controller property in the view object. Once I moved the html from the parent view template into its own html file and included that in the view object's templateUrl the issue was resolved!

image

soohoowoohoo avatar Mar 08 '16 19:03 soohoowoohoo

I tried the example suggested by @soohoowoohoo but it didn't work for me.

I discovered an other solution described below.

First I placed the HTML of the fields that was throwing the exceptions of Angular inside a NG-REPEAT code, and in JavaScript code of Angular I did a push inside the list when the interface was ready to be built.

Below my HTML before the changes: `

{{column.columnName}}

`

HTML after changes: `

{{column.columnName}}

`

In JavaScript, before to fill the information in my models to present the options of my md-select I set my NG-REPEAT model with an empty Array, like this: $scope.controls = [];

After all data got ready to be presented, I just append a new item in my array with this command. $scope.controls = [{}];

I used this code in 3 places of my application and it worked fine. These fields was in forms placed inside $mdDialog.

claudiozanin avatar Mar 22 '16 20:03 claudiozanin

#6048 https://github.com/angular/material/issues/6048#issuecomment-174176247 the error is reproduced here by @Undrium

jeson114 avatar Apr 11 '16 05:04 jeson114

@Undrium has already created this plunk which demonstrates this issue . @DevVersion @ThomasBurleson Have a look

http://plnkr.co/edit/8fgPvsNA5YDgKC9DDYKs

#6048

mohsinmuzawar avatar Apr 11 '16 08:04 mohsinmuzawar

@claudiozanin thanks, your solution works for me despite it strange look.

R-Kurbatovvakoms avatar Apr 11 '16 09:04 R-Kurbatovvakoms

Occurs from the second time I open the dialog.

ram-you avatar Apr 12 '16 17:04 ram-you

I solved my problem by adding to $mdDialog this option: autoWrap:false,

ram-you avatar Apr 12 '16 20:04 ram-you

@ram-you, I tried your solution but without any avail. Did you change anything else?

Undrium avatar Apr 13 '16 06:04 Undrium