Formerly called ng2-sidebar
An Angular sidebar component.
npm install --save ng-sidebar
If you're using SystemJS, be sure to add the appropriate settings to your SystemJS config:
const map = {
// ...
'ng-sidebar': 'node_modules/ng-sidebar',
// ...
};
const packages = {
// ...
'ng-sidebar': {
main: 'lib/index',
defaultExtension: 'js'
},
// ...
};
See the releases page on GitHub.
Add SidebarModule
to your app module:
import { SidebarModule } from 'ng-sidebar';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, SidebarModule.forRoot()],
bootstrap: [AppComponent],
})
class AppModule {}
In your app component, simply use add a <ng-sidebar-container>
wrapper, then place your <ng-sidebar>
(s) and content within it.
Your page content should be in some container with a ng-sidebar-content
attribute.
@Component({
selector: 'app',
template: `
<!-- Container for sidebar(s) + page content -->
<ng-sidebar-container>
<!-- A sidebar -->
<ng-sidebar [(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
<!-- Page content -->
<div ng-sidebar-content>
<button (click)="_toggleSidebar()">Toggle sidebar</button>
</div>
</ng-sidebar-container>
`
})
class AppComponent {
private _opened: boolean = false;
private _toggleSidebar() {
this._opened = !this._opened;
}
}
If nothing seems to show up, your wrappers' heights may be collapsing. Try adding a height (e.g. height: 100vh;
) to the wrapper <ng-sidebar-container>
or other wrapper elements you may have. (See issue #100 for more info.)
A directive is also provided to easily close the sidebar by clicking something inside it:
<ng-sidebar>
<a closeSidebar>Closes the sidebar</a>
</ng-sidebar>
You can also use the open()
and close()
functions:
<ng-sidebar #sidebar>
<button (click)="sidebar.close()">Close sidebar</button>
</ng-sidebar>
<button (click)="sidebar.open()">Open sidebar</button>
The sidebar has a few public functions:
Function | Description |
---|---|
open() |
Opens the sidebar. |
close() |
Closes the sidebar. |
triggerRerender() |
Manually trigger a re-render of the container. Useful if the sidebar contents might change. |
Various class names are attached to the sidebar and container for easier styling.
If you are using Angular's default emulated view encapsulation, you may have to use the >>>
selector to target the sidebar's classes. Check out Angular's documentation for more details. Note that the /deep/
selector will soon be deprecated.
Class name | Description |
---|---|
ng-sidebar |
Always on the sidebar element. |
ng-sidebar--opened |
When opened is true . |
ng-sidebar--closed |
When opened is false . |
ng-sidebar--left |
When position is 'left' (or the 'start' /'end' aliases are equivalent to 'left' ). |
ng-sidebar--right |
When position is 'right' (or the 'start' /'end' aliases are equivalent to 'right' ). |
ng-sidebar--top |
When position is 'top' . |
ng-sidebar--bottom |
When position is 'bottom' . |
ng-sidebar--over |
When mode is 'over' . |
ng-sidebar--push |
When mode is 'push' . |
ng-sidebar--slide |
When mode is 'slide' . |
ng-sidebar--docked |
When the sidebar is docked (i.e. it is "closed" and dock is true ). |
ng-sidebar--inert |
Ignores pointer clicks. Class is applied when the sidebar is closed. |
ng-sidebar--animate |
When animate is true for a sidebar. |
Class name | Description |
---|---|
ng-sidebar__backdrop |
Class of the backdrop div . Note that the div is only in the DOM when the backdrop is shown. |
Class name | Description |
---|---|
ng-sidebar__content |
Class of the wrapper div for the page content. |
ng-sidebar__content--animate |
When animate is true for the container. |
Property name | Type | Default | Description |
---|---|---|---|
contentClass | string | Additional class name on the div wrapping the page contents. |
|
backdropClass | string | Additional class name on the overlay element. | |
showBackdrop | boolean | false |
Controls the backdrop state of the sidebar container. This should be two-way bound. |
allowSidebarBackdropControl | boolean | true |
Determines if the container component respects the sidebar's showBackdrop input option. |
animate | boolean | true |
Animates the container sliding. |
Property name | Callback arguments | Description |
---|---|---|
showBackdropChange | showBackdrop: boolean |
Emitted when showBackdrop is modified. This allows for you to do "two-way binding" (i.e. [(showBackdrop)] ). |
onBackdropClicked | Emitted when a backdrop is clicked. |
Property name | Type | Default | Description |
---|---|---|---|
opened | boolean | false |
Controls the opened state of the sidebar. This should be two-way bound. |
mode | 'over' , 'push' , 'slide' |
'over' |
See the "Modes" section. |
dock | boolean | false |
Show the sidebar as docked when closed. |
dockedSize | string | '0px' |
When mode is set to 'dock' , this value indicates how much of the sidebar is still visible when "closed". |
position | 'left' , 'right' , 'top' , 'bottom' , 'start' , 'end' |
'start' |
What side the sidebar should be docked to. 'start' and 'end' are aliases that respect the page's language (e.g. start is the same as left for English, but would be right for Hebrew. |
autoCollapseHeight | number | Window height in pixels in which to automatically close the sidebar. | |
autoCollapseWidth | number | Window width in pixels in which to automatically close the sidebar. | |
autoCollapseOnInit | boolean | true |
Collapse sidebar based on autoCollapseHeight and/or autoCollapseWidth on initial render as needed. |
animate | boolean | true |
Animate the opening/closing of the sidebar. |
sidebarClass | string | Additional class name on the sidebar element. | |
ariaLabel | string | Value for the sidebar's aria-label attribute. |
|
trapFocus | boolean | false |
Keeps focus within the sidebar when open. Note that this only works if there's one sidebar open at a time. |
autoFocus | boolean | true |
Automatically focus the first focusable element in the sidebar when opened. |
showBackdrop | boolean | false |
If a translucent black backdrop overlay should appear over the page contents when the sidebar is opened. This is ignored if the sidebar's parent container has its allowSidebarBackdropControl property set to true . |
closeOnClickBackdrop | boolean | false |
Whether clicking on the backdrop of the open sidebar will close it. |
closeOnClickOutside | boolean | false |
Whether clicking outside of the open sidebar will close it. |
keyClose | boolean | false |
Close the sidebar when a keyboard button is pressed. |
keyCode | number | 27 |
The key code for keyClose . |
Property name | Callback arguments | Description |
---|---|---|
onContentInit | Corresponds with ngAfterContentInit lifecycle event of the sidebar component. |
|
openedChange | opened: boolean |
Emitted when opened is modified. This allows for you to do "two-way binding" (i.e. [(opened)] ). |
onOpenStart | Emitted when the sidebar is opening. | |
onOpened | Emitted when the sidebar is opened. | |
onCloseStart | Emitted when the sidebar is closing. | |
onClosed | Emitted when the sidebar is closed. | |
onTransitionEnd | Emitted when the animation for opening or closing ends. | |
onModeChange | mode: string |
Emitted when mode is changed. |
onPositionChange | position: string |
Emitted when position is changed. |
This is the default mode. The sidebar slides in over the page contents.
The page contents is pushed to make space for the sidebar.
The entire page slides over to show the sidebar. Note that this only works if you have one sidebar open at a time.
ng-sidebar's People
Forkers
lovjith diegofal inspectory limjoonae xaralis havocparasite ashtreecc bino98 charlesgouldmann shiptoncraig xuxinsheng derobiom mikulha asiftasleem guzuomuse husamui siovene dalbir rainstormza sifawm nathane2005 cloud925 dalhyncarrillo gsbybb alesce chronicbint somsakc usir2 andresg747 niilante nishaaan-angular-4 abdelhakmckee delgorx parasjain95 cgels julien-divron belphy16 mserbruyns urvesh21 ravivit9 yanioconjota wiraxie wofll-forks lukearthurs mdalmazzi sjohnsonstoever gstercken lwh-angular tesoknyra dileepunni1 yelner sivakumarganesan1 unistate mauriziocasciano daudihusbands assmass scssat zhiqinghuang klemense soorya02 eoff93 khanglvg pksilver ovidiubarbu kondusairaj vanthaiunghoa adriangomezg01 amjadalfawal tihomirmagdic mrcastegt anderstornkvist digideskio devlabpro lmaciascantillo ciss-cologne marcos280990 fyrehawk fernandolopestavares dinkapach areebaaroosh abhiman24 abocoum sergio00 talissonjunior rafael-uv jadzohee vicrodrima confusedfish imcber shalinee-walkover sajidit axel-lanuza francoiscx wuyou201400 yehonatangithub kkozlowski89 roshanlakmal weiyin1991 rfjhendriks kankabuitpng-sidebar's Issues
closeOnClickOutside
'closeOnClickOutside' doesn't work on iPhone Chrome (56.0.2824.79) and Safari (iOS 10.2.1)
Mode not working in angular 2
I have added mode properties which is not working at all am getting undefined error in my browser console any help
Sidebar not found
Greatings,
I have installed ng2-sibebar successfully
package.json:
"dependencies": {
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
"@angular/upgrade": "~2.1.0",
"angular-in-memory-web-api": "~0.1.5",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"ng2-sidebar": "^1.6.1",
app.module:
import { SidebarModule } from 'ng2-sidebar';
@NgModule({
imports: [ SidebarModule],
Error Message:
"(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/ng2-sidebar
Error: XHR error (404 Not Found) loading http://localhost:3000/ng2-sidebar
at wrapFn (http://localhost:3000/node_modules/zone.js/dist/zone.js:698:17)
at ZoneDelegate.prototype.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:263:17)
at Zone.prototype.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:154:21)
at invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:335:21)
Error loading http://localhost:3000/ng2-sidebar as "ng2-sidebar" from http://localhost:3000/app/app.module.js"
Add ability to dock to top/bottom
Optional animations
Attach event listeners attached on document instead of body
Hi, because i use a sticky footer my body cannot be 100% height. The closeOnClickOutside
wont work if i dont click the body.
https://github.com/arkon/ng-sidebar/blob/master/src/sidebar.component.ts#L369 document.addeventListener
would fix it
Adding/removing backdrop while sidebar open
I am using ng-sidebar in a project and need to be able to add/remove the backdrop while a sidebar is already open. Is this something you've ever considered implementing?
Documentation is far away from complete
openedChange
is not documented in the outputs
SidebarService
is not documented
Feature request: SidebarService
If you write a element with the closeSidebar directive directly on the lightdom of the ng2-sidebar all runs as expected.
@Component({
selector: 'my-app',
styles: [":host /deep/ ng2-sidebar aside { background-color: white }"],
template: `
<ng2-sidebar [(open)]="_open">
<p>Sidebar contents</p>
<a closeSidebar>Close</a>
</ng2-sidebar>
<button (click)="_toggleSidebar()">Toggle sidebar</button>
`
})
export class App {
private _open: boolean = false;
private _toggleSidebar() {
this._open = !this._open;
}
}
But, if you insert and component that includes the closeSidebar directive on the lightdom, the sidebar doesn't close.
@Component({
selector: 'my-app',
styles: [":host /deep/ ng2-sidebar aside { background-color: white }"],
template: `
<ng2-sidebar [(open)]="_open">
<p>Sidebar contents</p>
<close-sidebar></close-sidebar>
</ng2-sidebar>
<button (click)="_toggleSidebar()">Toggle sidebar</button>
`
})
export class App {
private _open: boolean = false;
private _toggleSidebar() {
this._open = !this._open;
}
}
@Component({
selector: 'close-sidebar',
template: `
<a closeSidebar>Close</a>
`
})
export class CloseSidebar{}
I think, and my team use this, ng2-sidebar needs a SidebarService that have a subscriber and the functions to execute this close function. With this, closeSidebar can put on any component inside or outside of the sidebar if it needed.
If you like, we can send a pull request with this feature.
Experimental support for decorators
I am able to install and start a local version of your repo but when i open a component in my editor, say the Sidebar class i get an error:
experimental support for decorators is a feature that is subject to change in a future release
Have you run into this before?
I am running tsc -v 1.8.10, if that helps?
Problems with AOT
Problems with AOT:
Error at /aot/node_modules/ng-sidebar/lib/sidebar-container.component.ngfactory.ts:93:44: Property '_sidebars' is private and only accessible within class 'SidebarContainer'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar-container.component.ngfactory.ts:194:44: Property '_showBackdrop' is private and only accessible within class 'SidebarContainer'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar-container.component.ngfactory.ts:197:44: Property '_getStyles' does not exist on type 'SidebarContainer'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar.component.ngfactory.ts:282:18: Property '_elSidebar' is private and only accessible within class 'Sidebar'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar.component.ngfactory.ts:304:44: Property '_getTransformStyle' does not exist on type 'Sidebar'.
Error at /aot/app/home/home.component.ngfactory.ts:188:44: Property '_sidebars' is private and only accessible within class 'SidebarContainer'.
Because private, protected accessors should be changed to public for any members accessed from template
ng2-sidebar on header component (angular 2) never hide when user click on body though I set closeOnClickOutside="true"
Not able to integrate ng2-sidebar in application
Hi
I am getting below error after following the steps :
localhost/:52 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-sidebar.js
Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-sidebar.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:647:29)
at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:236:37)
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:136:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:304:33)
Error loading http://localhost:3000/node_modules/ng2-sidebar.js as "ng2-sidebar" from http://localhost:3000/app/shared/shared.module.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:647:29)
at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:236:37)
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:136:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:304:33)
Error loading http://localhost:3000/node_modules/ng2-sidebar.js as "ng2-sidebar" from http://localhost:3000/app/shared/shared.module.js "Error while loading app"
Could you please help me on this?
Am i missing anything?
sidebarClass not working
Cannot import SidebarModule
Hello,
I have this error when I import SidebarModule in my @NgModule.
SyntaxError: export declarations may only appear at top level of a module (Browser's console Error)
I am using angular2 + meteor (latest version).
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SidebarModule } from 'ng-sidebar';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { AccountsModule } from 'angular2-meteor-accounts-ui';
import {Ng2PaginationModule} from 'ng2-pagination';
import { AgmCoreModule } from 'angular2-google-maps/core';
import { Select2Module } from 'ng2-select2';
import { AppComponent } from './app.component';
import { routes, ROUTES_PROVIDERS } from './app.routes';
import { DASHBOARD_DECLARATIONS } from './dashboard';
import { AUTH_DECLARATIONS } from "./authentication/index";
import { PARTIES_DECLARATIONS } from './parties';
import { CUSTOMERS_DECLARATIONS } from './customers';
import { SHARED_DECLARATIONS } from './shared';
import { ModalModule } from 'ng2-bootstrap/modal';
@NgModule({
imports: [
BrowserModule,
SidebarModule,
FormsModule,
ReactiveFormsModule,
RouterModule.forRoot(routes),
AccountsModule,
Ng2PaginationModule,
AgmCoreModule.forRoot({
apiKey: '*****'
}),
ModalModule.forRoot(),
Select2Module
],
declarations: [
AppComponent,
...AUTH_DECLARATIONS,
...CUSTOMERS_DECLARATIONS,
...DASHBOARD_DECLARATIONS,
...PARTIES_DECLARATIONS,
...SHARED_DECLARATIONS
],
providers: [
...ROUTES_PROVIDERS
],
bootstrap: [
AppComponent
]
})
export class AppModule {}
Styles on ng-sidebar not working
Update demo
I need to update it so it uses angular-cli/AOT and whatnot instead of the custom-spun Webpack stuff that's going on right now.
SideBar In a container
Hi,
I tried to implement sidebar inside the child component (an div container) without success.
Is this possible? Do you have an example how to implement this?
Thanks
Custom collapse amount
As requested in #14, it'd be nice to be able to specify the collapse amount so it's not always 110% (e.g. showing a thin portion when "collapsed").
Directive for closing sidebar.
It'd be nice to be able to throw a directive on contents in the sidebar indicating that clicking them would close the sidebar, like:
<ng2-sidebar>
<button closeSidebar>Something</button>
</ng2-sidebar>
Compatibility for browsers that not support Web Animations API
The module animate uses Web Animations API. This functionality is only for Firefox, Chrome, Opera and not completely. From the angular official docs recommends use web-animations.js
I think that is a good idea to add this advice to README.
Note: Thank you for the hard work.
Better way of styling
It would be nice if users could somehow pass styles as an object or something, instead of explicitly overriding the defaults via CSS?
Custom Sidebar animation
Howdy,
Is there a way to override thee default animation of the sidebar? (it pulls from left to right)
I only see the following on the documentation:
animate boolean true Animate the opening/closing of the sidebar.
I was wondering, since I'm doing some animations using angular2 api
Thanks,
e. Vazquez 😄
Sidebar does not work correctly in IE 11 in dock mode
I noticed while testing my own app that the sidebar does not work correctly in the internet explorer. I retried it with your showcase sidebar and the bug does also occur.
When the mode is set to dock, the sidebar is shown correctly:
Then after you open and close it, the content of the main page is behind the sidebar, instead of being pushed.
The system I use is Windows 7 64 bit with the Internet Explorer 11 .
The push mode per se works correctly in the ie.
Sidebar does not hide on iOS 8
First of all, animations don't work well on older mobile devices, we can live with that (and that's not the real issue). But if we turn them off, sidebar does not get hidden on old iOS. It seems to be an issue with a non-prefixed transform (see http://stackoverflow.com/questions/30128587/ios-safari-transition-transform-not-working).
Sidebar contents should be inert when closed
Contents are still keyboard-focusable when the sidebar is closed.
Add start/end aliases for positions
To better support different writing modes (e.g. RTL), the default position should simply be "start" instead of "left", adapting to the language as needed.
Unable to integrate with a new project created with angular-cli
Setup -
- OS - macOS Sierra 10.12.2
- Node - v6.9.2
- NPM - v4.0.4
- IDE - IntelliJ Idea CE
I am able to clone, compile and run the demo directly but not able to integrate ng-sidebar with my new angular-cli created project.
I have followed the instructions given in the readme.md file here
If I add just <ng-sidebar </ng-sidebar>
then it doesn't give any error. However if I add the content from the github readme file
<!-- Container for sidebar(s) + page content -->
<ng-sidebar-container>
<!-- A sidebar -->
<ng-sidebar [(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
<!-- Page content -->
<button (click)="_toggleSidebar()">Toggle sidebar</button>
</ng-sidebar-container>
then get following error.
Error -
Unhandled Promise rejection: Template parse errors:
Can't bind to 'opened' since it isn't a known property of 'ng-sidebar'.
1. If 'ng-sidebar' is an Angular component and it has 'opened' input, then verify that it is part of this module.
2. If 'ng-sidebar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
("
<!-- A sidebar -->
<ng-sidebar [ERROR ->][(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
"): AppComponent@4:18
'ng-sidebar-container' is not a known element:
1. If 'ng-sidebar-container' is an Angular component, then verify that it is part of this module.
2. If 'ng-sidebar-container' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<!-- Container for sidebar(s) + page content -->
[ERROR ->]<ng-sidebar-container>
<!-- A sidebar -->
"): AppComponent@1:4 ; Zone: <root> ; Task: Promise.then ; Value: SyntaxError {_nativeError: Error: Template parse errors:
Can't bind to 'opened' since it isn't a known property of 'ng-sidebar'…} Error: Template parse errors:
Can't bind to 'opened' since it isn't a known property of 'ng-sidebar'.
1. If 'ng-sidebar' is an Angular component and it has 'opened' input, then verify that it is part of this module.
2. If 'ng-sidebar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
("
<!-- A sidebar -->
<ng-sidebar [ERROR ->][(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
"): AppComponent@4:18
'ng-sidebar-container' is not a known element:
1. If 'ng-sidebar-container' is an Angular component, then verify that it is part of this module.
2. If 'ng-sidebar-container' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<!-- Container for sidebar(s) + page content -->
[ERROR ->]<ng-sidebar-container>
Touch support
Make sidebar responsive
Hi. It would be great if you can add option for automatic close sidebar when screen size is < 640px(for example) .
Problem running Karma tests after adding sidebar
This might be my fault when adding sidebar. But the sidebar shows up ok when running the website so it seems to work. The problem is that when running the karma tests I get the error pasted bellow. The problem seems to be that the array _closeDirectives.forEach is undefined for some reason when the test run. I'm new to javavscript and it seems to me like it could be the combination of tools that I use which triggers this issue. But I was thinking that it could be something to look at for stability reasons. I can send you the project that I have to trigger the issue if you are interested.
Chrome 53.0.2785 (Mac OS X 10.11.6)
Error: Error in /Users/perka124/Documents/dev/Java/StoryTeller/ui/dist/dev/app/app.component.html:0:0 caused by: Cannot read property 'forEach' of undefined
TypeError: Cannot read property 'forEach' of undefined
at Sidebar.ngOnDestroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/ng2-sidebar/lib/sidebar.component.js:58:30)
at DebugAppView._View_AppComponent0.destroyInternal (AppComponent.ngfactory.js:312:21)
at DebugAppView.AppView.destroyLocal (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9402:18)
at DebugAppView.destroyLocal (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9565:47)
at DebugAppView.AppView._destroyRecurse (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9390:18)
at DebugAppView.AppView._destroyRecurse (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9388:29)
at DebugAppView.AppView._destroyRecurse (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9388:29)
at DebugAppView.AppView.destroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9376:18)
at ComponentRef_.destroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:5911:86)
at ComponentFixture.destroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:302:35)
at eval (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:760:78)
at Array.forEach (native)
at TestBed.resetTestingModule (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:760:34)
at Function.TestBed.resetTestingModule (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:668:26)
at Object.eval (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:994:21)
at ZoneDelegate.invoke (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:203:28)
at ProxyZoneSpec.onInvoke (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/proxy.js:72:39)
at ZoneDelegate.invoke (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:202:34)
at Zone.run (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:96:43)
at Object.<anonymous> (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/jasmine-patch.js:91:50)
at ZoneQueueRunner.jasmine.QueueRunner.ZoneQueueRunner.execute (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/jasmine-patch.js:119:42)
at ZoneDelegate.invokeTask (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:236:37)
at Zone.runTask (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:136:47)
at drainMicroTaskQueue (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:368:35)
a
Add "focusFirstItem" input to enable/disable first focusable item autofocus.
Hi @arkon.
I'm developing an Angular2 app using your sidebar component and it's really good. The problem is that I have an input tag into a sidebar and it's autofocused when the sidebar opens. In desktop browsers it's not a big deal, but in mobile browsers it causes the keyboard to raise up automatically and it disturbs the user experience a little bit on my opinion. So what do you think about adding a "focusFirstItem" input flag on the sidebar component (that could be true by default) to avoid this in case the developer wants to? I'm able to make a PR if you agree.
Regards and thanks again!
Abstract event listeners
We're binding directly to document
right now, which might not work with things like web workers.
Might want to use Document
/BrowserDomAdapter
.
Set tab-index in sidenav
im not able to focus elements in side nav, how can i do this?
Can not use in a lazy-loaded feature module
Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.
We are trying to use the module in a lazy loaded feature module. The error comes because you can not import Browser Module in a feature module. By using the CommonModule it will be more universally usable.
I have updated it locally by replacing the BrowserModule import with the CommonModule import and it is now working.
Add option to push page content
It would be helpful to add the ability to select whether the sidebar overlays content or pushes it right|down|left|up depending on location i.e. change the z-index and other styles.
Example: http://semantic-ui.com/modules/sidebar.html
Or: https://github.com/angular/material2/tree/master/src/lib/sidenav
Is ng-sidebar unstyled
I've installed ng-sidebar in a clean angular-cli project (beta 30) and it comes up unstyled, as per the picture below? Is this by design or have I missed something?
I followed the instructions in the readme.md.
I installed using npm install ng-sidebar --save
My app.component.html file looks like this:
<!-- A sidebar -->
<ng-sidebar [(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
<!-- Page content -->
<button (click)="_toggleSidebar()">Toggle sidebar</button>
</ng-sidebar-container>
My app.component.ts file looks like this:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app works!';
private _opened: boolean = false;
private _toggleSidebar() {
this._opened = !this._opened;
}
}
And my app.module.ts looks like this:
import { SidebarModule } from 'ng-sidebar';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
SidebarModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Thank you for a great project and welcome your thoughts.
Update dist structure
It'd be nice if you could do something like:
import Sidebar from 'ng2-sidebar/sidebar';
angular-seed extension
Hi arkon,
I am not able to add this module to angular-seed. I have tried multiple ways like using the System Js configuraton, project.config.ts file but nothing works.
Position right not animating properly
I am positioning the '.ng-sidebar' as absolute and setting its position as 'right'. On chrome the sidebar goes out more than it should and once i hover on it, it snaps back into its proper place. While on firefox/other the animation is jittery.
Use Angular animations system
This goes hand in hand with #3. (Holding off until RC5)
Disable mouse click/hover events for page elements beneath the overlay
When using the showOverlay = true option, links and other DOM elements respond to my mouse cursor (hover styles and click events) when moving my mouse around the sidebar overlay.
This can cause an unexpected side effect of the user accidentally clicking a link when just trying to close the sidebar.
It would be much better to disable mouse events underneath the overlay, such as the behaviour of Bootstrap modals (http://getbootstrap.com/javascript/#modals).
I have had a quick look through the source code, and I can see 'pointer-events' is set to 'none', and I am not 100% sure how to approach fixing this.
Happy to attempt a fix and submit a PR if someone could point me in the right direction?
Thanks and good job on the package! 👍
user forRoot static method
Hi @arkon, i cant use this module in my shared module because of https://github.com/arkon/ng-sidebar/blob/master/src/sidebar.module.ts#L13
Use this instead:
static forRoot(): ModuleWithProviders {
return {
ngModule: SidebarModule,
providers: [SidebarService]
};
}
read more: https://angular.io/docs/ts/latest/guide/ngmodule.html#!#core-for-root
Keyboard event for closing sidebar
Option to press ESC (or some other key) to close the sidebar.
sidebarClass
Sidebar items remain inert
Keyclose=false ignored.
We are using the ng-sidebar with the keyClose input set to false and keycode left as default however the sidebar is still closing when the escape key is pressed.
Two Side bars and getting errors
Thanks for the component. We are building a proto-type app, and it's finding its spot in a good place.
I was able to utilize the sidebar on the right side and it works fine.
However, when I tried to add "two" sidebars with different #, I get this odd issue.
Error: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
at ExpressionChangedAfterItHasBeenCheckedError.ZoneAwareError (zone.js:992)
at ExpressionChangedAfterItHasBeenCheckedError.BaseError [as constructor] (errors.js:22)
at new ExpressionChangedAfterItHasBeenCheckedError (errors.js:59)
at checkBinding (view_utils.js:167)
at Wrapper_NgControlStatus.checkHost (/InternalFormsSharedModule/NgControlStatus/wrapper.ngfactory.js:33)
at View_NgTableComponent10.detectChangesInternal (/AppModule/NgTableComponent/component.ngfactory.js:715)
at View_NgTableComponent10.AppView.detectChanges (view.js:425)
at View_NgTableComponent10.DebugAppView.detectChanges (view.js:620)
at ViewContainer.detectChangesInNestedViews (view_container.js:67)
at View_NgTableComponent9.detectChangesInternal (/AppModule/NgTableComponent/component.ngfactory.js:845)
at View_NgTableComponent9.AppView.detectChanges (view.js:425)
at View_NgTableComponent9.DebugAppView.detectChanges (view.js:620)
at ViewContainer.detectChangesInNestedViews (view_container.js:67)
at CompiledTemplate.proxyViewClass.View_NgTableComponent0.detectChangesInternal (/AppModule/NgTableComponent/component.ngfa
The container for this is very simple one as below.
<ng-sidebar-container>
<!-- A sidebar -->
<ng-sidebar #bottombar
[(opened)]="_displayed"
[keyClose]="false"
[position]="'bottom'"
[mode]="'push'">
Test
<button>Test</button>
<!--<button type="button" class="btn btn-secondary" (click)="bottombar.close()">Cancel</button>-->
<!--<!–<button type="button" class="btn btn-secondary btn-sm" (click)="submit()">Delete</button>–>-->
<!--<button type="button" class="btn btn-primary" (click)="submit()">Save</button>-->
</ng-sidebar>
</ng-sidebar-container>
Am I doing something wrong here?
The "#" name for both sidebar are different. Above is "#bottombar", but the other one is called "sidebar"..
Any help is appreciated.
"closeSidebar" directive doesn't work with routerLink directive (angular 2.1.1)
angular 2.1.1
angular router 3.1.1
Is it possible to put the page content outside of the wrapper?
<ng-sidebar-container>
<!-- A sidebar -->
<ng-sidebar [(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
Test
</ng-sidebar-container>
Instead of above,
<ng-sidebar-container>
<!-- A sidebar -->
<ng-sidebar [(opened)]="_opened">
<p>Sidebar contents</p>
</ng-sidebar>
</ng-sidebar-container>
Content here..
That way, I can create my own component much easier by encapsulating the with it.
THanks.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.