-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using responsive API with md-sidenav or other html elements #64
Comments
So that is not currently possible. Only the Flex-Layout API understands the responsive aliases (e.g. html, body, material-app, md-sidenav-container, .my-content {
margin: 0;
width: 100%;
height: 100%;
} <app>
<responsive-sidenav>
<div sidenav-content>
Hello, I am a responsive sideNav component
</div>
<div main-content>
Hello, I am the primary, main content
</div>
</responsive-sidenav>
</app> Now let's use multi-slot, content projection within our Responsive-Sidenav component: @Component({
selector : 'responsive-sidenav',
template : `
<md-sidenav-container>
<md-sidenav mode="side" [opened]="isOpen">
<ng-content select="[sidenav-content]">Projected Drawer Content</ng-content>
</md-sidenav>
<div class="my-content">
<ng-content select="[main-content]">Main content</ng-content>
</div>
</md-sidenav-container>
`
})
export class ResponsiveSideNav implements OnDestroy {
private var _subscription;
isOpen = true;
constructor(@Inject(MatchMediaObservable) media$) {
this._subscription = media$.subscribe(change:MediaChange) => {
let isMobile = (change.alias == 'xs') || (change.alias == 'sm');
this.isOpen = !isMobile;
});
}
ngOnDestory() {
this._subscription.unsubscribe();
}
} DemosAlso you can review the source to our online Demo App: |
You guys are awesome! Thank you very much for your rapid response. I didn't expect it to be this quick honestly. Thanks Thomas |
@geelus - In the future, please post usage questions:
|
Thx @geelus . Sorry, I just made some corrections to my sample code ^.
|
Here is a Link to the responsive code in the Demo-App source: https://github.com/angular/flex-layout/blob/master/src/demo-app/app/docs-layout-responsive/responsiveFlexDirective.demo.ts#L45 |
Sure, I will. thanks again for your great help. |
@geelus - np. Give us a shoutout on Twitter. 🤓 |
@geelus - I prepared a Responsive-SideNav Plunkr showing how to use the MatchMediaObservable... only to discover a major bug: see issue #65 The Plunkr ^ has a work around and shows have a sidenav is now responsive.
|
@ThomasBurleson glad I could help. Yesterday I used your solution and it worked like a charm! I didn't notice the bug, maybe because I was so excited to see this working! Merry Christmas and Happy new year! |
@ThomasBurleson your example has a spelling mistake |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
At the moment thanks for Flex-Layout we can easily show or hide an element using the breakpoints.
Is there anyway to use flex-api to open/close the side nav in different resolutions? Something lik:
The text was updated successfully, but these errors were encountered: