ovsleep / bootstrap-switch

This is a Angular 2 Component to add a switch like input.
https://bootstrap-switch.herokuapp.com/
8 stars 10 forks source link

Unexpected value 'SwitchComponent' declared by the module 'AppModule' #6

Closed rochapablo closed 7 years ago

rochapablo commented 7 years ago

I'm getting:

Uncaught Error: Unexpected value 'SwitchComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.

app.module

import { SwitchComponent } from 'angular2-bootstrap-switch/components';
@NgModule({
  declarations: [
    AppComponent,
    SwitchComponent,
    ...

Using:

Angular: 4.2.0 Angular CLI: 1.0.6 angular2-bootstrap-switch: 0.1.9

ovsleep commented 7 years ago

I tried to tackle down this issue, but seems to be a mix up with the versions. I've created this component with Angular 2.0, I managed to make it work with this:

Angular: 4.0 Angular CLI: 1.0 (Demo page is like that)

But not with Angular 4.2-rc.1, found similar issue here but not clear solution. For now I'll stick with 4.0 since 4.2 is rc. Eventually I should rewrite the component for Angular 4. Help's welcome ;)

rochapablo commented 7 years ago

Changing to angular2-bootstrap-switch: 0.1.12 worked.

Now the layout seems... strange; but I'll look for what that could be and back if I cannot resolve.

For now, I appreciate your help.

rochapablo commented 7 years ago

Sorry, but I still having the same issue when I tried to build the project.

Running ng serve everything works fine; but if I run ng build --env=prod --aot I got:

ERROR in Unexpected value 'SwitchComponent in /.../node_modules/angular2-bootstrap-switch/lib/switch.component.d.ts' declared by the module 'AppModule in /.../src/app/components/index.ts'. Please add a @Pipe/@Directive/@Component annotation.
rochapablo commented 7 years ago

My bad, running ng build --env=prod worked.

ovsleep commented 7 years ago

Yea I saw this was happening, maybe is the same issue as here #10 I think it's an issue provoked by the angular version I used to create the project the first time, which was Angular 2. Using version 4> has this compatibility issues.

if running ng build --env=prod works OK and produce the same build, I think that's a good workaround.