Closed tonywong625 closed 8 years ago
Hi Sorry for long answer time. About slider - maybe problem in styling. HTML code of slider was rendered?
Hey, I absolutely can't get this thing to work too. I followed all of the instructions in the readme file, but slider won't render, and HTML markup aren't rendering too. I'm using latest Angular 2 RC4.
I was a bit surprised by not mentioning any directive include in the .ts file, maybe could this be the problem?
I installed this slider and dependencies through NPM.
My .TS file: (from your example)
`export class MyComponent {
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; } }`
My HTML template: (from your example too)
`<ng2-slider min="1" max="14" value="5" (onRangeChanged)="plainValueChanged($event, plain_1)">
Value: 5
` I really don't know where the problem is, if you could help, I would be very glad. Thank you.Hi Both this function are responsible for changing input box value only. Did you specify
directives: [Ng2SliderComponent, ...]
in @Component
decorator ?
What errors do you see in your browser console?
Hello Bogdan, thanks for your reply!
When I add this to directives, I get this error at console:
Uncaught ReferenceError: Ng2SliderComponent is not defined
After a little research I assumed it should be included in my component like this:
import {Ng2SliderComponent} from 'ng2-slider-component/ng2-slider.component';
When I save it like this, I get this error in console:
Uncaught TypeError: System.register is not a function
At this point I don't know what to try next. Maybe it would be nice if you provide a full install guide in your Readme file, I don't think I'm the only one confused.
Thank you for your help!
What module system do you use? This components prepared for System.js module system. https://angular.io/docs/ts/latest/quickstart.html Learning of this manual is required for understanding Angular 2 application's ecosystem
Your examples are not clear at all, because you don't specify which is the package that we should import, also i'm trying to make it work but when the "onRangeChanged" is fired i don't know what is the second parameter, i was supposing that it is a value from the plugin side but after continue reading there is lots of those variables (plain_1, plain_2, range-1-start, etc) so i don't know what is supposed that i have to provide as second parameter, also please remove the input field from the widget, it is ok for testing, but not for a real usage
Edit After read the plugin i notice that there is no a second parameter, the plugin is returning himself, why?
i don't need the component, i need the value and things like that
I use Webpack instead of SystemJS (my choice), so i can't use your component... !
I'm planning prepare it for Webpack, but it will be some later
Hi, jlberrocal
when the "onRangeChanged" is fired i don't know what is the second parameter
What U mean "second parameter"? "onRangeChanged" is event
also please remove the input field from the widget, it is ok for testing, but not for a real usage
Yes, It will be optional in next version
the plugin is returning himself, why?
To have ability to change values in widget. Maybe callback will be better solution for this. Maybe. I'll think about this.
Thank you for your notes
To whoever looking that ng2-slider is not working,
In angular-cli-build.js
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist//*.+(js|js.map)',
'es6-shim/es6-shim.js',
'reflect-metadata//.+(ts|js|js.map)',
'rxjs//.+(js|js.map)',
'@angular//*.+(js|js.map)',
'@angular2-material//',
'ng2-slideable-directive/*',
'ng2-styled-directive/*',
'ng2-slider-component/*'
]
});
};
Then in system-config.js
const map: any = {
'@angular2-material': 'vendor/@angular2-material',
'ng2-slideable-directive':'vendor/ng2-slideable-directive',
'ng2-styled-directive':'vendor/ng2-styled-directive',
'ng2-slider-component':'vendor/ng2-slider-component'
};
/** User packages configuration. */
const packages: any = {
'ng2-slideable-directive':{
main:`*.js`
},
'ng2-styled-directive':{
main:`*.js`
},
'ng2-slider-component':{
main:`*.js`
}
};
In your componentname.component.js file
import {Ng2SliderComponent} from 'ng2-slider-component/ng2-slider.component';
@Component({
moduleId: module.id,
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
directives: [MD_BUTTON_DIRECTIVES, MD_TOOLBAR_DIRECTIVES, Ng2SliderComponent]
})
This works for me.
Component was recompiled, using Common JS modules. So, now it is compatible with both Webpack and SystemJS.
I'm publish new version with SystemJS compatible files to npm
*.js files compiled for WebPack
If you use SystemJS, you have to use *.system.js
files, they are compiled for SystemJS.
Fragment of SystemJS config:
packages: {
....
'node_modules/ng2-slider-component': {
main: 'ng2-slider.component.system.js',
defaultExtension: 'system.js'
},
....
}
Hi. I cannot make it works.
I've installed the component and dependency with npm --save I've imported the component with:
import { Ng2SliderComponent } from 'ng2-slider-component/ng2-slider.component';
And declared in my ngModule:
declarations: [ Ng2SliderComponent ]
When my application loads I get the error in the console:
Uncaught Error: moduleId should be a string in "Ng2SliderComponent"
Thanks.
Hi I had the same error as Luperco . did you find out what can be the issue
Hello I had the same error "Error: moduleId should be a string in "Ng2SliderComponent", Can someone say what might be the issue. Am using WebPack module bundler
Hi,
Did you update this package for angular2/webpack? Any news on how long will take to be compatible with webpack?
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.
For Webpack users, I was able to resolve this issue. I removed the moduleId for the ng2-slider-component component.
Follow these steps:
1) Navigate to node_modules/ng2-slider-component/ng2-slider.component.js
2) In the component definition (~ lines 400-405), remove the moduelId keyword and value (i.e. delete the line moduleId: module.id
).
For more info about moduleId refer to this SO post: http://stackoverflow.com/questions/37178192/angular2-what-is-the-meanings-of-module-id-in-component
@prasadkopanati ! perfect this is the only thing that needs to be changed for it to work in webpack.
Hi @prasadkopanati I tried by removing the moduleId:module.id line in the ng2-slider-component.js file that issue was gone but strangely i was getting
Error: Template parse errors:↵Can't bind to 'styleBlock' since it isn't a known property of 'div'. ("ontainer ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" bla bla.....
if i add module.id line getting need string in "Ng2SliderComponent". Am using webpack.
I facing below error message in console
Uncaught ReferenceError: require is not defined
at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9),
and my angular-cli.json file looks like
"../node_modules/jquery/dist/jquery.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js", "../node_modules/element-resize-detector/dist/element-resize-detector.min.js", "../node_modules/cropperjs/dist/cropper.js", "../node_modules/bootstrap-slider/dist/bootstrap-slider.min.js", "../node_modules/bootstrap-slider/dist/bootstrap-slider.js", "../node_modules/ng2-slider-component/ng2-slider.component.js", "../node_modules/ng2-slideable-directive/slideable.directive.js", "../node_modules/ng2-styled-directive/ng2-styled.directive.js"
and I included import { Ng2SliderComponent } from "ng2-slider-component/ng2-slider.component"; it module.ts file
and my html code looks like
<ng2-slider min="1" max="14" value="5" (onRangeChanged)="plainValueChanged($event, 'plain_1')">
Is anybody solved this problem in angular 2?If yes help me out to fix this...
I gave up. I found something else.
Can you share me the link if possible of what you found?
On Sat, Apr 21, 2018 at 4:48 PM, Emanuele Benedetti < notifications@github.com> wrote:
I gave up. I found something else.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Bogdan1975/ng2-slider-component/issues/1#issuecomment-383286322, or mute the thread https://github.com/notifications/unsubscribe-auth/AkraOtkt6FHK5OEdAozd5j6Nt6L06V-nks5tqxWfgaJpZM4I8XYK .
Hey there, I have followed the installation and the same HTML markup, however the slider isnt displaying.