How to create range slider in angular 5

Ashok picture Ashok · Apr 9, 2018 · Viewed 10.6k times · Source

I tried ng2-ion-range-slider and ng2-nouislider using documentation described in github. When i add these component it showing "it is not a known element of ngModule" I import ng2-nouislider, ng2-ion-range-slider in my app module

APP MODULE

import 'hammerjs';
import {SharedModule} from './core/modules/shared.module';
import {AppComponent} from './app.component';
import {VoifinityMainModule} from './main/main.module';
import {FuseSplashScreenService} from './core/services/splash-screen.service';
import {VoifinityConfigService} from './core/services/config.service';
import {FuseNavigationService} from './core/components/navigation/navigation.service';
import {AppRoutingModule} from './app-routing.module';
import {AuthenticationModule} from './authentication/authentication.module';
import {VoifinityAuthInterceptor} from './core/auth/voifinity-auth.interceptor';
import {AuthService} from './core/auth/auth.service';
import {AuthGuardService} from './core/auth/auth-guard.service';
import {SimpleNotificationsModule} from 'angular2-notifications';
import {AppService} from './app.service';
import {NgHttpLoaderModule} from 'ng-http-loader/ng-http-loader.module';
import {IonRangeSliderModule} from 'ng2-ion-range-slider';


@NgModule({
    declarations: [
        AppComponent
    ],
    imports     : [
        BrowserModule,
        HttpClientModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        SimpleNotificationsModule.forRoot(),
        AuthenticationModule,
        VoifinityMainModule,
        NgHttpLoaderModule,
        IonRangeSliderModule
    ],
    providers   : [
      AuthService,
      AppService,
      AuthGuardService,
      {
        provide: HTTP_INTERCEPTORS,
        useClass: VoifinityAuthInterceptor,
        multi: true
      },
        FuseSplashScreenService,
        VoifinityConfigService,
        FuseNavigationService
    ],
    bootstrap   : [
        AppComponent
    ]
})
export class AppModule
{
}

app.component.html, added ion-range slider component. but it shows template parse error. ion-range-slider is not a known element

<ion-range-slider #sliderElement
          type="double"
          [min]="myMinVar"
          max="100"
          from="28"
          from_min="10"
          from_max="30"
          from_shadow="true"
          to="40"
          to_min="40"
          to_max="90"
          to_shadow="true"
          grid="true"
          grid_num="10"
          prefix="Weight: "
          postfix=" million pounds"
          decorate_both="false"
          (onUpdate)="myOnUpdate($event)"
          (onChange)="myOnChange($event)"
          (onFinish)="myOnFinish($event)"></ion-range-slider>

Answer

bugs picture bugs · Apr 9, 2018

Seems to be working fine in my case after installing the required dependencies, have a look at my working demo.

Don't forget to include NouisliderModule in the imports of your app.module, and @import "~nouislider/distribute/nouislider.min.css"; in your styles.css