Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$mdDialog opens but with the following error. Cannot read property 'getBoundingClientRect'

I am trying to generate a dialogue when an icon is clicked. I get the following error when I click on the md-icon. The dialogue opens, but I see the following error on my console:

TypeError: Cannot read property 'getBoundingClientRect' of undefined
at transformToClickElement (angular-material.js:4652)
at dialogPopIn (angular-material.js:4630)
at Object.onShow (angular-material.js:4538)
at InterimElementFactory.self.show.compilePromise.then.showDone (angular-material.js:1827)
at processQueue (angular.js:13248)
at angular.js:13264
at Scope.$get.Scope.$eval (angular.js:14466)
at Scope.$get.Scope.$digest (angular.js:14282)
at Scope.$get.Scope.$apply (angular.js:14571)
at done (angular.js:9698)                               

angular-material.js:824 Uncaught TypeError: Cannot read property 'hasAttribute' of undefined

Below is my HTML snippet.

<md-button class="md-fab md-primary" ng-click="showAdvanced($event)"
           aria-label="AddClient">
    <md-icon md-svg-src="content/images/68448.svg" 
             style="width: 48px; height: 48px;">
    </md-icon>

    <md-tooltip md-visible="demo.showTooltip">
        Add Client
    </md-tooltip>
</md-button>

Controller of the HTML page is below.

$scope.showAdvanced = function(ev) {
$mdDialog.show({
  controller: 'newClient',
  templateUrl: 'app/views/xyz/newClient.html',
  targetEvent: ev
});};

Dialog HTML

    <md-content class="md-padding" layout="row" layout-sm="column" style="font-size:1.2em">
        <form name="myForm" >
            <div layout layout-sm="column">
                <md-input-container style="width:80%">
                    <label>Name</label>
                    <input ng-model="create.Name">
                </md-input-container>
            </div>
</md-content>

Thanks

like image 617
user4321 Avatar asked Nov 30 '22 17:11

user4321


1 Answers

You are missing a wrapping md-dialog tag. According to the docs:

The dialog's template must have an outer md-dialog element. Inside, use an md-content element for the dialog's content, and use an element with class md-actions for the dialog's actions.

Try this:

<md-dialog>
  <md-content>
    <md-button class="md-fab md-primary" ng-click="showAdvanced($event)" aria-label="AddClient">
      <md-icon md-svg-src="content/images/68448.svg" style="width: 48px; height: 48px;"></md-icon>

      <md-tooltip md-visible="demo.showTooltip">
        Add Client
      </md-tooltip>
    </md-button>
  </md-content>
</md-dialog>
like image 122
Darnell Campbell Avatar answered May 19 '23 22:05

Darnell Campbell