Cannot read property top of undefined ngx bootstrap
Offcanvas is a sidebar component that can be toggled via JavaScript to appear from the left, right, or bottom edge of the viewport. Buttons or anchors are used as triggers that are attached to specific elements you toggle, and
Show 0 attributes are used to invoke our JavaScript.
Heads up! Given how CSS handles animations, you cannot use
1 or
2 on an
3 element. Instead, use the class as an independent wrapping element. ExamplesOffcanvas componentsBelow is an offcanvas example that is shown by default (via
4 on
3). Offcanvas includes support for a header with a close button and an optional body class for some initial
6. We suggest that you include offcanvas headers with dismiss actions whenever possible, or provide an explicit dismiss action.
Live demoUse the buttons below to show and hide an offcanvas element via JavaScript that toggles the
4 class on an element with the
3 class.
You can use a link with the
1 attribute, or a button with the
2 attribute. In both cases, the
3 is required. Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
PlacementThere’s no default placement for offcanvas components, so you must add one of the modifier classes below;
Try the top, right, and bottom examples out below.
BackdropScrolling the
8 element is disabled when an offcanvas and its backdrop are visible. Use the
9 attribute to toggle
8 scrolling and
1 to toggle the backdrop. Try scrolling the rest of the page to see this option in action.
AccessibilitySince the offcanvas panel is conceptually a modal dialog, be sure to add
2—referencing the offcanvas title—to
3. Note that you don’t need to add
4 since we already add it via JavaScript. SassVariables
UsageThe offcanvas plugin utilizes a few classes and attributes to handle the heavy lifting:
Add a dismiss button with the
0 attribute, which triggers the JavaScript functionality. Be sure to use the
1 element with it for proper behavior across all devices. Via data attributesAdd
3 and a
2 or
1 to the element to automatically assign control of one offcanvas element. The
2 attribute accepts a CSS selector to apply the offcanvas to. Be sure to add the class
6 to the offcanvas element. If you’d like it to default open, add the additional class
7. Via JavaScriptEnable manually with:
OptionsOptions can be passed via data attributes or JavaScript. For data attributes, append the option name to
8, as in
9. Name Type Default Description
0 boolean
1 Apply a backdrop on body while offcanvas is open
2 boolean
1 Closes the offcanvas when escape key is pressed
4 boolean
5 Allow body scrolling while offcanvas is open MethodsAsynchronous methods and transitionsAll API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored. How do you fix undefined properties Cannot be read?The error can be fixed by creating a variable to hold the name of the file. This will fix the error and will not change anything in your application. What is undefined property error in Angular?The “cannot read property of undefined” error can occur when you are trying to access a variable or a property that has not been declared yet. This error can also happen if you try to access an implicit template that has not been loaded yet. Is ngxngx-bootstrap provides Bootstrap components powered by Angular, so you don't need to include original JS components. Check our Getting started guide if it's your first project with Angular Bootstrap. How to pass data to ngxTo demonstrate the data flow to and from Bootstrap modals, I will create the following scenario:. define and create an object in a parent component.. pass that object into a modal component.. edit that object in the modal component.. pass it back to the parent component.. |