答案 0 :(得分:11)
I had a lot of trouble finding a way to do this in material2. Finally, I found this way reading the source-code:
<md-sidenav opened="true" disableClose="true">
答案 1 :(得分:1)
您可以通过向其添加以下属性来保持导航栏对于您希望的任何视图:
CREATE TABLE ID_CARD(
ID INTEGER NOT NULL AUTO_INCREMENT,
N_CARD VARCHAR(20) NOT NULL,
ISSUE_DATE DATE NOT NULL,
ID_TYPE VARCHAR(2) NOT NULL,
CONSTRAINT PKEY_ID_CARD PRIMARY KEY(ID),
CONSTRAINT UI_ID_CARD UNIQUE INDEX(N_CARD,ISSUE_DATE)
);
检查Angular Docs以参考。
答案 2 :(得分:1)
对于较新版本,请将let previousValue = realm.objects(FormAnswer.self).filter("key == %@ AND ANY form.id == %@", key, parentForm!.id).first?.answer
添加到[opened]="true"
元素
<md-sidenav>
答案 3 :(得分:0)
请查看此代码段。基本上,您可以使用$mdSidenav("sidenavId").toggle()
切换sidenav。
angular.module('materialApp', ['ngMaterial', 'ngAnimate'])
.controller('homeCtrl', ['$scope', '$mdSidenav', function($scope, $mdSidenav) {
$scope.toggleSideNav = function() {
$mdSidenav('leftNav').toggle();
};
}]);
&#13;
.ma-sidenav {
background: rgb(16,108,200);
}
.btn-row {
padding-top: 30px;
text-align: center;
}
.btn-toggle {
display: inline-block;
}
.sidenav-item {
padding: 10px 10px 10px 30px;
color: white;
}
&#13;
<link href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.4/angular-material.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.4/angular-material.min.js"></script>
<body ng-app="materialApp">
<section ng-controller="homeCtrl">
<md-sidenav class="md-sidenav-left md-whiteframe-z2 ma-sidenav" md-component-id="leftNav">
<div class="sidenav-item">Item 1</div>
<div class="sidenav-item">Item 2</div>
<div class="sidenav-item">Item 3</div>
<div class="sidenav-item">Item 4</div>
</md-sidenav>
<md-content flex layout-padding>
<div class="btn-row">
<md-button class="md-raised btn-toggle" ng-click="toggleSideNav()">Toggle SideNav</md-button>
</div>
</md-content>
</section>
</body>
&#13;
答案 4 :(得分:0)
Whether the drawer can be closed with the escape key or by clicking on the backdrop.
但是当我点击其中的某个元素(?)时,我们有3个选项可以关闭sidenav
和3d。为了防止你需要覆盖回调,或者例如我曾经sidenav
进行响应式设计,这个答案对我很有用https://github.com/angular/material2/issues/1130#issuecomment-299888690
答案 5 :(得分:0)
当我按下Esc按钮时,我的侧面小门关闭了。然后我添加了
<mat-sidenav mode="side" opened [disableClose]="true">
解决了我的问题。