Angular UI Components Documentation

Angular PasswordInput Component

The PasswordInput component for Angular represents a widget which enables you to input passwords with nice visual feedback about the password's strength.

1. Installation

The easiest way to get started with jQWidgets UI for Angular is to use the Angular CLI Tool. To scaffold your project structure, follow its installation instructions.

npm install -g @angular/cli
ng new jqwidgets-project
cd jqwidgets-project

Install jQWidgets

jQWidgets Angular UI comes packaged with Angular CLI schematics to make creating Angular applications easier. Schematics are included with both @angular/cdk and jqwidgets-ng. Once you install the npm packages, they will be available through the Angular CLI.

Angular CLI supports the addition of packages through the ng add command. The ng add command provides faster and more user-friendly package installation. To install the jQWidgets UI for Angular package, use ng add and add the name of the NPM package:

ng add jqwidgets-ng

Alternatively, you can use the standard installation (Manual Setup)

jQWidgets UI for Angular is distributed as jqwidgets-ng NPM package

  1. Download and install the package.
    npm install jqwidgets-ng
  2. Adding CSS reference

    The following CSS file is available in ../node_modules/jqwidgets-ng/ package folder. This can be referenced in [src/styles.css] using following code.

    @import 'jqwidgets-ng/jqwidgets/styles/jqx.base.css';

    Another way to achieve the same is to edit the angular.json file and in the styles add the style.

    "styles": [
    	"node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css"
    ]
    

2. Add the HTML for jQWidgets component in src/app/app.component.html

app.component.html


<jqxExpander [theme]="'fluent'" #createAccount
             [showArrow]="false"
             [toggleMode]="'none'"
             [width]="350">
    <div>
        Create a new account
    </div>
    <div style="font-family: Verdana; font-size: 13px;">
        <jqxValidator #validatorReference (onValidationSuccess)="validationSuccess($event)" [rules]="rules" [hintType]="'label'">
            <form id="form" style="overflow: hidden; margin: 10px;" action="./">
                <table>
                    <tr>
                        <td colspan="2">
                            First Name
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <jqxInput [theme]="'fluent'" #firstName class="firstName" [width]="300" [height]="21"></jqxInput>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Last Name
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <jqxInput [theme]="'fluent'" #lastName class="lastName" [width]="300" [height]="21"></jqxInput>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Choose your username
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <jqxInput [theme]="'fluent'" #userName class="userName" [width]="300" [height]="21"></jqxInput>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Create a password
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <jqxPasswordInput [theme]="'fluent'" #password class="password" [width]="300" [height]="21"></jqxPasswordInput>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Confirm your password
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <jqxPasswordInput [theme]="'fluent'" #passwordConfirm class="passwordConfirm" [width]="300" [height]="21"></jqxPasswordInput>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Birthday
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <jqxDateTimeInput [theme]="'fluent'" #birthday class="birthday"
                                              [width]="300"
                                              [height]="21">
                            </jqxDateTimeInput>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Gender
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <jqxDropDownList [theme]="'fluent'" #gender class="gender"
                                             [source]="genders"
                                             [selectedIndex]="-1"
                                             [placeHolder]="'I am...'"
                                             [autoDropDownHeight]="true"
                                             [width]="300"
                                             [height]="21">
                            </jqxDropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <jqxButton (onClick)="buttonClicked()">Create account</jqxButton>
                        </td>
                    </tr>
                </table>
            </form>
        </jqxValidator>
    </div>
</jqxExpander>	

3. Setup Component Logic

app.component.ts


import { Component, ViewChild } from '@angular/core';

import { jqxExpanderComponent, jqxExpanderModule } from 'jqwidgets-ng/jqxexpander';
import { jqxInputComponent, jqxInputModule } from 'jqwidgets-ng/jqxinput';
import { jqxValidatorComponent, jqxValidatorModule } from 'jqwidgets-ng/jqxvalidator';
import { jqxDropDownListComponent, jqxDropDownListModule } from 'jqwidgets-ng/jqxdropdownlist';
import { jqxDateTimeInputComponent, jqxDateTimeInputModule } from 'jqwidgets-ng/jqxdatetimeinput';
import { jqxButtonComponent, jqxButtonModule } from 'jqwidgets-ng/jqxbuttons';

import { jqxPasswordInputModule, jqxPasswordInputComponent } from 'jqwidgets-ng/jqxpasswordinput';

@Component({
    selector: 'app-root',
    imports: [jqxPasswordInputModule, jqxButtonModule, jqxExpanderModule, jqxInputModule, jqxDropDownListModule, jqxValidatorModule, jqxDateTimeInputModule],
    standalone: true,
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})

export class AppComponent {
    @ViewChild('createAccount') createAccount: jqxExpanderComponent;
    @ViewChild('firstName') firstName: jqxInputComponent;
    @ViewChild('lastName') lastName: jqxInputComponent;
    @ViewChild('userName') userName: jqxInputComponent;
    @ViewChild('password') password: jqxPasswordInputComponent;
    @ViewChild('passwordConfirm') passwordConfirm: jqxPasswordInputComponent;
    @ViewChild('validatorReference') myValidator: jqxValidatorComponent;
    @ViewChild('gender') gender: jqxDropDownListComponent;

    genders: string[] = ["male", "female"];

    rules: any[] = [
        {
            input: ".firstName", message: "First name is required!", action: 'keyup, blur', rule: (input: any, commit: any): boolean => {
                return this.firstName.val() != "" && this.firstName.val() != "First"
            }
        },
        {
            input: ".lastName", message: "Last name is required!", action: 'keyup, blur', rule: (input: any, commit: any): boolean => {
                return this.lastName.val() != "" && this.lastName.val() != "Last";
            }
        },
        { input: ".userName", message: "Username is required!", action: 'keyup, blur', rule: 'required' },
        { input: ".password", message: "Password is required!", action: 'keyup, blur', rule: 'required' },
        { input: ".passwordConfirm", message: "Password is required!", action: 'keyup, blur', rule: 'required' },
        {
            input: ".passwordConfirm", message: "Passwords should match!", action: 'keyup, blur', rule: (input: any, commit: any): boolean => {
                let firstPassword = this.password.val();
                let secondPassword = this.passwordConfirm.val();

                return firstPassword == secondPassword;
            }
        },
        {
            input: ".gender", message: "Gender is required!", action: 'blur', rule: (input: any, commit: any): boolean => {
                let index = this.gender.getSelectedIndex();

                return index != -1;
            }
        }
    ];

    buttonClicked(): void {
        this.myValidator.validate(document.getElementById('form'));
    };

    validationSuccess(event: any): void {
        this.createAccount.setContent('<span style="margin: 10px;">Account created.</span>');
    };
}

Summary

jQWidgets UI for Angular provides an easy way to integrate robust UI components into your Angular project. By using either the ng add command or manual setup, you can quickly get started. Once the setup is complete, you can add the desired jQWidgets components and configure them in your Angular components to match your application requirements.

PasswordInput API

API Reference of the jQWidgets PasswordInput component for Angular: PasswordInput API