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

ngModel' since it isn't a known property of 'ui-switch' #227

Closed
javascriptDC opened this issue Feb 26, 2018 · 8 comments
Closed

ngModel' since it isn't a known property of 'ui-switch' #227

javascriptDC opened this issue Feb 26, 2018 · 8 comments

Comments

@javascriptDC
Copy link

ngModel is not working properly.
Issue:
compiler.es5.js:1694 Uncaught Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'ui-switch'.

  1. If 'ui-switch' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.

  2. If 'ui-switch' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

         <ui-switch [ERROR ->][(ngModel)]="enable"></ui-switch>
       </div>
    
<ui-switch [(ngModel)]="enable"></ui-switch>
enable = true;
@javascriptDC
Copy link
Author

I downgrade this module into 1.4.4 because of MetaData version mismatch error with version 1.4.9.

Could you provide any good solution with me, please?

@cmckni3
Copy link
Collaborator

cmckni3 commented Feb 26, 2018

This may have been what I was talking about in #189

@javascriptDC
Copy link
Author

When downgrading it into 1.4.4, the two-way binding is not working.

@cmckni3
Copy link
Collaborator

cmckni3 commented Feb 26, 2018

Yes and that's why I mentioned #189. I will look into the ngModel issue when I have a chance. For now, use the change event and update your variable manually.

@cmckni3
Copy link
Collaborator

cmckni3 commented Mar 2, 2018

Can't reproduce on 1.5.0. The demo works fine in the 1.x-stable branch with Angular 4.

Have you imported the module UiSwitchModule?

@cmckni3 cmckni3 closed this as completed Mar 2, 2018
@vinayadepu
Copy link

vinayadepu commented Jul 16, 2019

  1. Point properly ngx-ui-swith module in app.module
    such as
    import { UiSwitchModule } from '../../node_modules/ngx-ui-switch';
  2. In angular.json include below script
    "styles": [
    "node_modules/ngx-ui-switch/ui-switch.component.css"
    ],

@cmckni3
Copy link
Collaborator

cmckni3 commented Jul 16, 2019

@vinayadepu that import is not correct and those instructions are in the README

@FinlayDaG33k
Copy link

Sorry for necro'ing this issue but I want to point out for people coming by here that one can also import it in the shared.module.ts to have it available for all components.

// shared.module.ts
import { UiSwitchModule } from 'ngx-toggle-switch';

@NgModule({
  imports: [UiSwitchModule, ...],
  exports: [UiSwitchModule, ...]
})
export class SharedModule{}

Repository owner locked as resolved and limited conversation to collaborators Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants