Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can i open 'mdbottomsheet ' over another 'mdbottomsheet ' in Angularjs Material?

I'm beginner in AngularJs Material, I want to open a 'mdbottomsheet' and put a button inside this sheet, when click button, open another 'mdbottomsheet' over, without closing the first 'mdbottomsheet'.

There is HTML code:

<div ng-controller="MyController">
  <md-button ng-click="openBottomSheet()">
     Open a Bottom Sheet!
  </md-button>
</div>

There Js:

var app = angular.module('app', ['ngMaterial']);
app.controller('MyController', function($scope, $mdBottomSheet) {
  $scope.openBottomSheet = function() {
    $mdBottomSheet.show({
    controller: 'BottomSheet',
    template: '<md-bottom-sheet>Hello!
             <md-button ng-click="openSecondBottomSheet()">
                Open Second Bottom Sheet!
             </md-button></md-bottom-sheet>'
  });
 };
});

and in 'BottomSheet' controller:

var app = angular.module('app', ['ngMaterial']);
app.controller('BottomSheet', function($scope, $mdBottomSheet) {
  $scope.openSecondBottomSheet = function() {
    $mdBottomSheet.show({
    controller: 'SecondBottomSheet',
    template: '<md-bottom-sheet>Hello!</md-bottom-sheet>'
  });
 };
});

This is my codes, it works but when 'SecondBottomSheet' opened, first 'BottomSheet' closed! i want to open 'SecondBottomSheet' over the first 'BottomSheet'!

like image 589
MHS Avatar asked Feb 19 '17 17:02

MHS


1 Answers

The $mdBottomSheet.show() returns a promise which can be used to check if the bottom sheet has closed. You can emulate the same by using the promise to close the first bottom sheet on click of your button and open another bottom sheet. When the second bottom sheet closes, you can again open your first bottom sheet.

like image 130
Vikrant Yadav Avatar answered Oct 04 '22 04:10

Vikrant Yadav