【问题标题】:How to create range slider in angular 5如何在角度 5 中创建范围滑块
【发布时间】:2018-09-18 12:18:22
【问题描述】:

我使用 github 中描述的文档尝试了 ng2-ion-range-slider 和 ng2-nouislider。 当我添加这些组件时,它显示“它不是 ngModule 的已知元素” 我在我的应用模块中导入 ng2-nouislider、ng2-ion-range-slider

应用模块

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,添加离子范围滑块组件。但它显示模板解析错误。 ion-range-slider 不是已知元素

<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>

【问题讨论】:

  • 你能展示你的 app.module 吗?
  • @bugs 我刚刚在上面列出了

标签: angular5 rangeslider


【解决方案1】:

安装所需的依赖项后,在我的情况下似乎工作正常,看看我的working demo

不要忘记在 app.module 的导入中包含 NouisliderModule,在 styles.css 中包含 @import "~nouislider/distribute/nouislider.min.css";

【讨论】:

  • 它不工作,你能把你的 Skype id 发给我吗?我有一些屏幕截图
  • 您能否详细说明一下,究竟是什么不起作用?你看到任何错误吗?你检查过我的例子吗?
  • package.json "ng2-nouislider": "1.7.7" style.css @import "~nouislider/distribute/nouislider.min.css";应用模块从“ng2-nouislider”导入{NouisliderModule};在我的 component.html
  • 是的,我也在用这个版本
  • 显示的错误是 core.js:1440 错误错误:未捕获(在承诺中):错误:模板解析错误:无法绑定到“min”,因为它不是“nouislider”的已知属性'。 (" ][min]="0" [max]="10" [step]="0.05" [(ngModel)]= "someRange">
猜你喜欢
  • 2014-07-06
  • 2020-10-24
  • 2021-10-20
  • 1970-01-01
  • 2018-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多