I'm using sidenav directive from Angular Material. When we click out of the component, sidenav will be closed. What is the event broadcasted at that time?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In your controller
use $watch to check the return value of isOpen()
:
$scope.$watch(
function () {
return $mdSidenav('left').isOpen();
},
function (newValue, oldValue) {
console.log(newValue);
if (newValue == false) {
var button = angular.element(document.querySelector('#navButton'))
button.removeAttr('md-focused')
}
});
回答2:
If you look at the directive there is a function to detect,
self.close = function() { return self.$toggleOpen( false ); };
Here is the SideNav
directive