xandor-io / angular-material-sidemenu

A small component to make sidenav menus using Angular Material
MIT License
63 stars 50 forks source link

TypeError: Cannot read property '$parent' of undefined #44

Open Komald opened 6 years ago

Komald commented 6 years ago

angular-material-sidemenu version: 1.0.5 I am using gulp to build and serve my web app. When I am using gulp-serve the project is starting from my root/src/main/ folder and angular-material-sidemenu is working properly.

but when I do gulp-build, a build is getting generated and saved in root/build/www and angular-material-sidemenu is getting compressed and saved in vendor.js file.

                 <md-sidemenu-group>
                      <md-sidemenu-button ui-sref="journal">
                          <md-icon md-svg-src="content/images/PL_Services.svg">book</md-icon>
                          <span data-translate="sidebar.menu.journal">journal</span>
                      </md-sidemenu-button>
                  </md-sidemenu-group>

This is working correctly and journal state is loaded, but

                  <md-sidemenu-group>
                    <md-sidemenu-content collapse-other="true" md-svg-icon="content/images/PL_Contacts.svg" md-heading="{{'sidebar.menu.contacts.title'|translate}}" md-arrow="true">
                      <md-sidemenu-button ui-sref="contacts">
                        <md-icon class="ng-binding ng-scope material-icons" role="img">person</md-icon>
                        <span data-translate="sidebar.menu.contacts.view">View</span>
                      </md-sidemenu-button>

                      <md-sidemenu-button ui-sref="trustContact">
                        <md-icon class="ng-binding ng-scope material-icons" role="img">person_add</md-icon>
                        <span data-translate="sidebar.menu.contacts.new">Add</span>
                      </md-sidemenu-button>
                    </md-sidemenu-content>
                  </md-sidemenu-group>

is not expanding and showing the two buttons inside the md-sidemenu-content.

It's throwing error TypeError: Cannot read property '$parent' of undefined.

material-sidemenu-err

Komald commented 6 years ago

It seems that while collapse-other="true" its breaking at

angular.element(allmenu[i]).scope().$parent.$mdSidemenuContent.visible = false;

It's somehow not able to handle scope() of angular.element(allmenu[i]) and that is throwing the undefined error