2X faster development
The ultimate Angular UI toolkit to boost your development speed.
A quick start project that helps you to create an Angular 11 Checkbox with minimal code configurations. The following section explains you how to create a simple angular 11 Check Box component. Prerequisites
Before start, we need following items to create Angular Check Box in Angular 11 application.
Dependencies
npm install -g @angular/cli@11.2.3
Note: If you would like to follow and run the application in Angular 6 or Angular 5 or Angular 4, you need to replace the CLI command version number with the corresponding angular version number.
npm install -g @angular/cli@<CLI VERSION>
ng new angular11-app cd angular11-app
Adding Angular Checkbox
npm install @syncfusion/ej2-angular-buttons –save
The --save command will instruct the NPM to include a CheckBox package inside the dependencies section of the package.json.
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { CheckBoxModule } from '@syncfusion/ej2-angular-buttons'; import { AppComponent } from './app.component'; import { enableRipple } from '@syncfusion/ej2-base'; enableRipple(true); @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, CheckBoxModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule {}
@import "../node_modules/@syncfusion/ej2-base/styles/material.css"; @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `<ejs-checkbox label='Default'></ejs-checkbox>` }) export class AppComponent {}
ng serve
Once the files are compiled successfully, it will serve the site at localhost:4200 Screenshot:
Change the CheckBox state
The CheckBox checked property is used to handle the checked and unchecked state. In checked state a tick mark will be added to the visualization of CheckBox. Indeterminate
CheckBox indeterminate state can be set through indeterminate property. CheckBox indeterminate state masks the real value of CheckBox visually. CheckBox cannot be changed to indeterminate state through the user interface, this state can be achieved only through the property. [app.component.ts] import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `<ul> <li><ejs-checkbox label="Checked State" [checked]="true"></ejs-checkbox></li> <li><ejs-checkbox label="Unchecked State"></ejs-checkbox></li> <li><ejs-checkbox label="Indeterminate State" [indeterminate]="true"></ejs-checkbox></li> </ul>` }) export class AppComponent { } Screenshot:
Summary
Refer to our documentation and online samples for more features. If you have any queries, please let us know in comments below. You can also contact us through our Support forum or Direct-Trac. We are happy to assist you! |
2X faster development
The ultimate Angular UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.