J.Olufsen
J.Olufsen

Reputation: 13915

How to pass current object inside ng-repeat to $mdDialog?

Dialog should include details of currently selected product. How to make it work?

At the moment this doesn't work: <h2>Order: {{product.name}}</h2>

CodePen

Upvotes: 2

Views: 785

Answers (1)

michelem
michelem

Reputation: 14590

You need to pass locals property:

In ng-click add the product:

<md-button class="md-primary md-raised" ng-click="showAdvanced($event, product)">

In the Dialog pass it as locals:

$mdDialog.show({
      controller: DialogController,
      templateUrl: 'orderDialog.tmpl.html',
      parent: angular.element(document.body),
      targetEvent: ev,
      clickOutsideToClose: true,
      fullscreen: useFullScreen,
      locals:{dataToPass: product},
    })

In the Controller assign it to the scope:

var mdDialogCtrl = function ($scope, dataToPass) { 
    $scope.product = dataToPass  
}

Codepen updated

Upvotes: 4

Related Questions