Comments (10)
@Feof In my application I get this error if a user tries to navigate to another view (regardless of whether or not the new view has a carousel or not) before slide data has been received.
The following code worked for me.
I'm getting slide data from an API in the parent component. Once a response from the API has been received, I set loaded to true and pass the slides array to my carousel component.
<ng-container *ngIf="loaded else loading">
<app-carousel [slides]="slides" *ngIf="(slides && slides.length)"></app-carousel>
</ng-container>
from ngx-slick.
the same for me
from ngx-slick.
ngx-slick.umd.js In which there are two code blocks:
SlickComponent.prototype.ngOnDestroy = function () { this.unslick(); };
SlickItemDirective.prototype.ngOnDestroy = function () {
this.carousel.removeSlide(this)
so the real problem is if we are using "slick" inside OneComponent and then we are navigating to TwoComponent, then due to routing OneComponent get destroys along with our "slick" configuration variable.
And after that our "slick" library runs above two blocks which need component's slick configuration, which is not available because it's already destroyed and we get mentioned error.(Cannot read property 'slick' of undefined)
from ngx-slick.
This is a duplicate of #6
You can use the ngIf structural directive to only include the element or component containing the carousel if there is at least one slide.
from ngx-slick.
depiction:you answer always same. The problem born when leave a view that has a slide for a new view. Do you explain me how I should use that ngif?
I have a template:
<a [routerLink]="['/event', 3]">bye bye</a>
<div class="card">
<h5 class="card-header">..</h5>
<div class="card-block">
<ngx-slick *ngIf="slides && slides.length" class="carousel" #slickModal="slick-modal" [config]="slideConfig">
<div ngxSlickItem *ngFor="let slide of slides[0]" class="slide">
..
</div>
</ngx-slick>
</div>
</div>
If a click on element a, it crash.
from ngx-slick.
Your context is very specific.
All persons, except you, have my same problem.
Tomorrow I see the source code.
Is app-carousel a directive ?
I do not know why you do not have this problem
from ngx-slick.
app-carousel
is a component.
When creating a component using the Angular CLI, the component's selector, by default, is always "app-[component-name]".
Feel free to try my technique, which requires moving the carousel to a separate component.
from ngx-slick.
Also I have a separate component. I have </ component> and inside ngx-slick. you use that slides, I do not know what to do. However, I think the author left the project.
from ngx-slick.
I'm using the slider inside of a modal that may or may not be opened, and I get the error when navigating if the modal was never opened, so there are some unique factors. Preferably, the library would be changed to null check before calling unslick. But I got around it for now with this kludge-y bit of code:
` ngAfterContentInit() {
if (this.isVisible) {
this.ngxSlick.initSlick();
}
else {
this.ngxSlick.$instance = {};
this.ngxSlick.$instance.slick = (input) => { };
}
}`
from ngx-slick.
Closed. open new issue if any question.
from ngx-slick.
Related Issues (20)
- Responsive Option doesn't work HOT 12
- ngx-slick syntaxerror: unexpected token import angular universal
- Example URL not working
- Responsive: How to set only one side and use arrows on Iphone 10
- I tried to auto Increment the slide but I could not do that can any one tell how I can do that .. HOT 1
- I'm trying to execute a lazy load but when i instert the HTML code <img data-lazy="{{ slide.img }}" /> but this doesn't works
- I'm trying to integrate Bootstrap 4 with their grid system but this happens
- message of verbose Violation
- Previous button (arrow) not working properly
- Access Slick modal from component HOT 1
- initialSlide property not working for angular 6
- Logs error for non-passive event listener on touchstart and touchemove event. HOT 1
- routerLink is being followed on swipe HOT 1
- move slide HOT 1
- Compatibilty with Angular 8
- Responsive breakpoint not working with angular 7
- When `centerMode` is set to true the `slidesToScroll` property setting is ignored.
- Binding it`s not working!! HOT 1
- This package not working with angular 9 ivy. static forRoot(): ModuleWithProviders; HOT 3
- error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s). HOT 4
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.
from ngx-slick.