Bogdan1975 / ng2-slider-component

Angular 2 slider component
MIT License
68 stars 50 forks source link

ng2-slider is not working with Angular 2 CLI project #18

Open RamitAnandSharma opened 8 years ago

RamitAnandSharma commented 8 years ago

Here is my code: ERROR: metadata_resolver.js:700Uncaught Error: moduleId should be a string in "Ng2SliderComponent". See https://goo.gl/wIDDiL for more information. If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.

` In angular-cli.json

{
  "project": {
    "version": "1.0.0-beta.15",
    "name": "testbed-app"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": "assets",
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.css", 
        "../node_modules/font-awesome/css/font-awesome.css", 
        "styles.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/bootstrap/dist/js/bootstrap.js",
        "../node_modules/tether/dist/js/tether.js", 
        "../node_modules/ng2-slider-component/ng2-slider.component.js" 
      ],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [
    "../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2)"
  ],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}

then in package.json

{
  "name": "testbed-app",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "angular2-calendar": "^0.3.3",
    "angular2-ui-switch": "^1.1.0",
    "bootstrap": "^3.3.7",
    "bootstrap-slider": "^9.2.0",
    "core-js": "^2.4.1",
    "font-awesome": "^4.6.3",
    "fullcalendar": "^3.0.1",
    "jquery": "^3.1.1",
    "jquery-knob": "^1.2.11",
    "moment": "^2.15.1",
    "ng2-slider-component": "^1.0.9",
    "primeng": "^1.0.0-beta.17",
    "primeui": "^4.1.15",
    "rxjs": "5.0.0-beta.12",
    "tether": "^1.3.7",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.15",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.5",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  }
}

then in app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routes';

import { AppComponent } from './app.component';
import { HeaderComponent } from './template/header/header.component';
import { ConfigurationComponent } from './view/configuration/configuration.component'; 
import { Ng2SliderComponent } from "ng2-slider-component/ng2-slider.component";

@NgModule({
  declarations: [
    AppComponent,
    HeaderComponent,
    ConfigurationComponent,
    Ng2SliderComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    routing    
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Then in configration.component.ts

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-configuration',
  templateUrl: './configuration.component.html',
  styleUrls: ['./configuration.component.css']
})
export class ConfigurationComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }
  plainValueChanged(event, container:any) {
      var el = this.getElement(container);
      //el.innerText = event.startValue;
  }

  getElement(data){
      if (typeof(data)=='string') {
          return document.getElementById(data);
      }
      if (typeof(data)=='object' && data instanceof Element) {
          return data;
      }
      return null;
  }
}
bjornharvold commented 8 years ago

+1

ghost commented 8 years ago

Yeah I've got the same issue :(

derailed commented 8 years ago

+1. Any resolve on this?

ghost commented 8 years ago

I've switched to PrimeNG, their slider is pretty good as well.

Hassan0Rehman commented 7 years ago

Hi, same issue as above. I see error "Error: moduleId should be a string in "Ng2SliderComponent". See https://goo.gl/wIDDiL for more information." on console. The error message doesn't make any sense to me. Some solution would be help, i am using webpack.

sheetaldshivdas commented 7 years ago

Same issue still there cannot use this component in angular 2 cli based project. Will there be a proper fix made available?

iain17 commented 7 years ago

I see a fix here: #12 but it's ridiculous that we have to edit a file to get it to work.

darin-cardin commented 7 years ago

As far as I can tell, this tool is no longer maintained and does not work. I spent two hours trying to get this working. Don't make my mistake.

Ram-SR commented 7 years ago

@rolandoldengarm Can you please send me a demo link of PrimeNG slider?

ghost commented 7 years ago

@Ram-SR : https://www.primefaces.org/primeng/#/slider