B-3PO / angular-material-expansion-panel

Material Design Expansion Panels for Angular Material
MIT License
71 stars 25 forks source link

Error when run the example #31

Closed cmbreki closed 7 years ago

cmbreki commented 7 years ago

Hello, I get the following error when i try the page example: "ExpansionPanel 'panelOne' is not available! Did you use md-component-id='panelOne'?" Any ideas?

B-3PO commented 7 years ago

what branch did you pull?

cmbreki commented 7 years ago

I used bower install. Should i pull the master branch?

B-3PO commented 7 years ago

Thats why, you need to pull a branch and run gulp. You can pull master or any of the release branches.

chetanku commented 7 years ago

I am still not able to get it work. I took the master branch followed by: npm install gulp build The build goes fine. I see the js and css getting updated in the dist folder. gulp test passes and I get the error:

angular.js:14328 ExpansionPanel 'panelOne' is not available! Did you use md-component-id='panelOne'? angular.js:14328 TypeError: Cannot read property 'expand' of undefined ..

Code samples works fine.

I tried bower install as well instead of pulling the master branch but that too fails with the same error. any help will be great.

B-3PO commented 7 years ago

I need a little more info.

  1. What version of angular?
  2. What browser(s)?
  3. Is this the test app that i wrote, or are you using your own code? 3.5. If this is your own code, can you post it.
chetanku commented 7 years ago
  1. I am using angular version # 1.6.1
  2. Chrome
  3. The test app you wrote works fine. My code I have attached my code below, It is a sample app I am writing to explore angular-material-expansion-pane.

index.html.txt app.js.txt

Appreciate your help.

B-3PO commented 7 years ago

If you look at the code, there are 2 styles (async, sync). The Sync style is causing your error. Remove that line of code($mdExpansionPanel('panelOne').expand();) and just use the async style.

The problem is that angular has not yet rendered the panel at the time you are calling for it. That is why we have the waitfor method.

chetanku commented 7 years ago

Thanks Ben.