UNPKG

angular-material-npfixed

Version:

The Angular Material project is an implementation of Material Design in Angular.js. This project provides a set of reusable, well-tested, and accessible Material Design UI components. Angular Material is supported internally at Google by the Angular.js, M

73 lines (67 loc) 2.19 kB
angular .module('sidenavDemo1', ['ngMaterial']) .controller('AppCtrl', function ($scope, $timeout, $mdSidenav, $log) { $scope.toggleLeft = buildDelayedToggler('left'); $scope.toggleRight = buildToggler('right'); $scope.isOpenRight = function(){ return $mdSidenav('right').isOpen(); }; /** * Supplies a function that will continue to operate until the * time is up. */ function debounce(func, wait, context) { var timer; return function debounced() { var context = $scope, args = Array.prototype.slice.call(arguments); $timeout.cancel(timer); timer = $timeout(function() { timer = undefined; func.apply(context, args); }, wait || 10); }; } /** * Build handler to open/close a SideNav; when animation finishes * report completion in console */ function buildDelayedToggler(navID) { return debounce(function() { // Component lookup should always be available since we are not using `ng-if` $mdSidenav(navID) .toggle() .then(function () { $log.debug("toggle " + navID + " is done"); }); }, 200); } function buildToggler(navID) { return function() { // Component lookup should always be available since we are not using `ng-if` $mdSidenav(navID) .toggle() .then(function () { $log.debug("toggle " + navID + " is done"); }); }; } }) .controller('LeftCtrl', function ($scope, $timeout, $mdSidenav, $log) { $scope.close = function () { // Component lookup should always be available since we are not using `ng-if` $mdSidenav('left').close() .then(function () { $log.debug("close LEFT is done"); }); }; }) .controller('RightCtrl', function ($scope, $timeout, $mdSidenav, $log) { $scope.close = function () { // Component lookup should always be available since we are not using `ng-if` $mdSidenav('right').close() .then(function () { $log.debug("close RIGHT is done"); }); }; });