Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RamitAnandSharma opened this issue Oct 9, 2016 · 10 comments
Open

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

RamitAnandSharma opened this issue Oct 9, 2016 · 10 comments

Comments

@RamitAnandSharma
Copy link

RamitAnandSharma commented Oct 9, 2016

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

+1

@ghost
Copy link

ghost commented Nov 10, 2016

Yeah I've got the same issue :(

@derailed
Copy link

+1. Any resolve on this?

@ghost
Copy link

ghost commented Nov 20, 2016

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

@Hassan0Rehman
Copy link

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

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

@iain17
Copy link

iain17 commented May 25, 2017

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

@darin-cardin
Copy link

darin-cardin commented Sep 20, 2017

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

Ram-SR commented Nov 13, 2017

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

@ghost
Copy link

ghost commented Nov 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants