Ng2-slider component ERROR TypeError: cannot read the component of the undefined property

I am trying to use this Angular 2 plugin because I need a NG2 number slider, which I can configure the background panel and handle for: https://github.com/Bogdan1975/ng2-slider-component

I see an example of work here: http://bogdan1975.imtqy.com/slider/

But when I try to use the Angular CLI in my new project, I have problems. I used this as a link to fix some of the problems: https://github.com/Bogdan1975/ng2-slider-component/issues/12

Namely, to add these 3 packages to mine package.json dependencies:

"ng2-slideable-directive": "^1.0.13",
"ng2-slider-component": "^1.0.9",
"ng2-styled-directive": "^1.0.5"

Then in mine app.moduleI add them as follows:

//...
import { Ng2SliderComponent } from 'ng2-slider-component/ng2-slider.component';
import { SlideAbleDirective } from 'ng2-slideable-directive/slideable.directive';
import { Ng2StyledDirective } from 'ng2-styled-directive/ng2-styled.directive';

//...

@NgModule({
    declarations: [ 
        //...
        SlideAbleDirective,
        Ng2StyledDirective,
        Ng2SliderComponent
    ],
    // ...
    exports: [
        Ng2SliderComponent,
        Ng2StyledDirective
    ],
    //...

module.id, + "" line 401 ng2-slider.component.js

, , :

Ng2SliderComponent.ngfactory.js: 199 TypeError: 'component' undefined     Ng2StyledDirective.ngAfterViewInit(vendor.bundle.js: 24206)      callProviderLifecycles (vendor.bundle.js: 12979)      ElementProvidersLifecycles (vendor.bundle.js: 12954)      LifecycleHooksChildrenFirst (vendor.bundle.js: 12938)      checkAndUpdateView (vendor.bundle.js: 14043)      ViewAction (vendor.bundle.js: 14400)      execComponentViewsAction (vendor.bundle.js: 14332)      checkAndUpdateView (vendor.bundle.js: 14041)      ViewAction (vendor.bundle.js: 14400)      execComponentViewsAction (vendor.bundle.js: 14332)

, . ? , , NG2, ... : https://material.angular.io/components/slider/overview , ( , MDL, , .) , , !

Edit

, , :

var component = (<any>this._view)._element.component;

, , , - : https://github.com/angular/angular/issues/8277#issuecomment-288285510

, NG 4:

(<any>this._view.injector).view.context
+4

Source: https://habr.com/ru/post/1682823/


All Articles