Ngx-Bootstrap – Useful Resources

Ngx-Bootstrap – Useful Resources ”; Previous Next The following resources contain additional information on Ngx-Bootstrap. Please use them to get more in-depth knowledge on this. Useful Video Courses Bootstrap Online Training 27 Lectures 2 hours Tutorialspoint More Detail Bootstrap By Building Projects – Includes Bootstrap 4 Featured 162 Lectures 14.5 hours Eduonix Learning Solutions More Detail Master class Bootstrap 5 Course – Responsive Web Design 77 Lectures 6 hours Frahaan Hussain More Detail Bootstrap and jQuery – Training Course for Beginners 86 Lectures 4 hours YouAccel More Detail Learn Bootstrap – For Beginners 45 Lectures 2.5 hours YouAccel More Detail JavaScript, Bootstrap, and PHP – Training for Beginners 117 Lectures 5.5 hours YouAccel More Detail Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Quick Guide

Ngx-Bootstrap – Quick Guide ”; Previous Next Ngx-Bootstrap – Overview The ngx-bootstrap is a very popular library to use bootstrap components in Angular Based projects. It contains almost all core components of Bootstrap. ngx-bootstrap components are by design modular,extensible and adaptable. Following are the key highlighting points of this bootstrap library. Flexibility All components are modular by design. Custom templates, Styles can be applied easily. All components are extensible and adaptable and works on desktop and mobile with same ease and performance. Support All components uses latest style guides and guidelines for code maintainability and readablity. All components are fully unit tested and supports latest angular versions. Extensive Documentation All components are richly documented and well written. All components are have multiple working demos to exihibits multiple types of functionalities. Open Source ngx-bootstrap is open source project. It is backed by MIT License. Ngx-Bootstrap – Environment Setup In this chapter, you will learn in detail about setting up the working environment of ngx-bootstrap on your local computer. As ngx-bootstrap is primarily for angular projects, make sure you have Node.js and npm and angular installed on your system. Create an angular project First create a angular project to test ngx-bootstrap components using following commands. ng new ngxbootstrap It will create an angular project named ngxbootstrap. Add ngx-bootstrap as dependency You can use the following command to install ngx-bootstrap in newly created project− npm install ngx-bootstrap You can observe the following output once ngx-bootstrap is successfully installed − + [email protected] added 1 package from 1 contributor and audited 1454 packages in 16.743s Now, to test if bootstrap works fine with Node.js, create the test component using following command − ng g component test CREATE src/app/test/test.component.html (19 bytes) CREATE src/app/test/test.component.spec.ts (614 bytes) CREATE src/app/test/test.component.ts (267 bytes) CREATE src/app/test/test.component.css (0 bytes) UPDATE src/app/app.module.ts (388 bytes) Clear content of app.component.html and update it following contents. app.component.html <app-test></app-test> Update content of app.module.ts to include ngx-bootstrap accordion module. We”ll add other module in subsequent chapters. Update it following contents. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion” @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule.forRoot() ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } Update content of index.html to include bootstrap.css. Update it following contents. index.html <!doctype html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>Ngxbootstrap</title> <base href=”/”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <link rel=”icon” type=”image/x-icon” href=”favicon.ico”> <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css” rel=”stylesheet”> </head> <body> <app-root></app-root> </body> </html> In next chapter, we”ll update test component to use ngx-bootstrap components. Ngx-Bootstrap – accordion Accordion is a control to display collapsible panels and it is used to display information in limited space. AccordionComponent Displays collapsible content panels for presenting information in a limited amount of space. selector accordion Inputs closeOthers − boolean, if true expanding one item will close all others isAnimated − boolean, turn on/off animation, default: false AccordionPanelComponent AccordionHeading Instead of using heading attribute on the accordion-group, you can use an accordion-heading attribute on any element inside of a group that will be used as group”s header template. selector accordion-group, accordion-panel Inputs heading − string, Clickable text in accordion”s group header isDisabled − boolean, enables/disables accordion group isOpen − boolean, Is accordion group open or closed. This property supports two-way binding panelClass − string, Provides an ability to use Bootstrap”s contextual panel classes (panel-primary, panel-success, panel-info, etc…). Outputs isOpenChange − Emits when the opened state changes AccordionConfig Configuration service, provides default values for the AccordionComponent. Properties closeOthers − boolean, Whether the other panels should be closed when a panel is opened. Default: false isAnimated − boolean, turn on/off animation Example As we”re going to use accordion, We”ve updated app.module.ts to use AccordionModule as in ngx-bootstrap Environment Setup chapter. Update test.component.html to use the accordion. test.component.html <accordion> <accordion-group heading=”Open By Default” [isOpen]=”open”> <p>Open By Default</p> </accordion-group> <accordion-group heading=”Disabled” [isDisabled]=”disabled”> <p>Disabled</p> </accordion-group> <accordion-group heading=”with isOpenChange” (isOpenChange)=”log($event)”> <p>Open Event</p> </accordion-group> </accordion> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit } from ”@angular/core”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { open: boolean = true; disabled: boolean = true; constructor() { } ngOnInit(): void { } log(isOpened: boolean){ console.log(isOpened); } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200 and verify the following output. Ngx-Bootstrap – Alerts Alerts provides contextual messages for typical user actions like info, error with available and flexible alert messages. AlertComponent Displays collapsible content panels for presenting information in a limited amount of space. selector alert,bs-alert Inputs dismissible − boolean, If set, displays an inline “Close” button, default: false dismissOnTimeout − string | number, Number in milliseconds, after which alert will be closed isOpen − boolean, Is alert visible, default: true type − string, alert type. Provides one of four bootstrap supported contextual classes: success, info, warning and danger, default: warning Outputs onClose − This event fires immediately after close instance method is called, $event is an instance of Alert component. onClosed − This event fires when alert closed, $event is an instance of Alert

Ngx-Bootstrap – Typeahead

Ngx-Bootstrap – Typeahead ”; Previous Next ngx-bootstrap Typeahead directive provides a easy to use and highly configurable, easy to use Typeahead component. TypeaheadDirective selector [typeahead] Inputs adaptivePosition − boolean, sets use adaptive position. container − string, A selector specifying the element the typeahead should be appended to. dropup − boolean, This attribute indicates that the dropdown should be opened upwards, default:false. isAnimated − boolean, turn on/off animation, default:false. optionsListTemplate − TemplateRef<TypeaheadOptionListContext>, used to specify a custom options list template. Template variables: matches, itemTemplate, query. typeahead − Typeahead, options source, can be Array of strings, objects or an Observable for external matching process. typeaheadAsync − boolean, should be used only in case of typeahead attribute is Observable of array. If true – loading of options will be async, otherwise – sync. true make sense if options array is large. typeaheadGroupField − string, when options source is an array of objects, the name of field that contains the group value, matches are grouped by this field when set. typeaheadHideResultsOnBlur − boolean, used to hide result on blur. typeaheadIsFirstItemActive − boolean, makes active first item in a list. Default:true. typeaheadItemTemplate − TemplateRef<TypeaheadOptionItemContext>, used to specify a custom item template. Template variables exposed are called item and index. typeaheadLatinize − boolean, match latin symbols. If true the word súper would match super and vice versa.Default: true. typeaheadMinLength − number, minimal no of characters that needs to be entered before typeahead kicks-in. When set to 0, typeahead shows on focus with full list of options (limited as normal by typeaheadOptionsLimit) typeaheadMultipleSearch − boolean, Can be used to conduct a search of multiple items and have suggestion not for the whole value of the input but for the value that comes after a delimiter provided via typeaheadMultipleSearchDelimiters attribute. This option can only be used together with typeaheadSingleWords option if typeaheadWordDelimiters and typeaheadPhraseDelimiters are different from typeaheadMultipleSearchDelimiters to avoid conflict in determining when to delimit multiple searches and when a single word. typeaheadMultipleSearchDelimiters − string, should be used only in case typeaheadMultipleSearch attribute is true. Sets the multiple search delimiter to know when to start a new search. Defaults to comma. If space needs to be used, then explicitly set typeaheadWordDelimiters to something else than space because space is used by default OR set typeaheadSingleWords attribute to false if you don”t need to use it together with multiple search. typeaheadOptionField − string, when options source is an array of objects, the name of field that contains the options value, we use array item as option in case of this field is missing. Supports nested properties and methods. typeaheadOptionsInScrollableView − number, Default value: 5,specifies number of options to show in scroll view typeaheadOptionsLimit − number, maximum length of options items list. The default value is 20. typeaheadOrderBy − TypeaheadOrder, Used to specify a custom order of matches. When options source is an array of objects a field for sorting has to be set up. In case of options source is an array of string, a field for sorting is absent. The ordering direction could be changed to ascending or descending. typeaheadPhraseDelimiters − string, should be used only in case typeaheadSingleWords attribute is true. Sets the word delimiter to match exact phrase. Defaults to simple and double quotes. typeaheadScrollable − boolean, Default value: false, specifies if typeahead is scrollable typeaheadSelectFirstItem − boolean, Default value: true, fired when an options list was opened and the user clicked Tab If a value equal true, it will be chosen first or active item in the list If value equal false, it will be chosen an active item in the list or nothing typeaheadSingleWords − boolean, Default value: true, Can be use to search words by inserting a single white space between each characters for example ”C a l i f o r n i a” will match ”California”. typeaheadWaitMs − number, minimal wait time after last character typed before typeahead kicks-in typeaheadWordDelimiters − string, should be used only in case typeaheadSingleWords attribute is true. Sets the word delimiter to break words. Defaults to space. Outputs typeaheadLoading − fired when ”busy” state of this component was changed, fired on async mode only, returns boolean. typeaheadNoResults − fired on every key event and returns true in case of matches are not detected. typeaheadOnBlur − fired when blur event occurs. returns the active item. typeaheadOnSelect − fired when option was selected, return object with data of this option. Example As we”re going to use a Typeahead, We”ve to update app.module.ts used in ngx-bootstrap Timepicker chapter to use TypeaheadModule. Update app.module.ts to use the TypeaheadModule. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule,AlertConfig } from ”ngx-bootstrap/alert”; import { ButtonsModule } from ”ngx-bootstrap/buttons”; import { FormsModule } from ”@angular/forms”; import { CarouselModule } from ”ngx-bootstrap/carousel”; import { CollapseModule } from ”ngx-bootstrap/collapse”; import { BsDatepickerModule, BsDatepickerConfig } from ”ngx-bootstrap/datepicker”; import { BsDropdownModule,BsDropdownConfig } from ”ngx-bootstrap/dropdown”; import { PaginationModule,PaginationConfig } from ”ngx-bootstrap/pagination”; import { PopoverModule, PopoverConfig } from ”ngx-bootstrap/popover”; import { ProgressbarModule,ProgressbarConfig } from ”ngx-bootstrap/progressbar”; import { RatingModule, RatingConfig } from ”ngx-bootstrap/rating”; import { SortableModule, DraggableItemService } from ”ngx-bootstrap/sortable”; import { TabsModule, TabsetConfig } from ”ngx-bootstrap/tabs”; import { TimepickerModule } from ”ngx-bootstrap/timepicker”; import { TypeaheadModule } from ”ngx-bootstrap/typeahead”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot(), BsDropdownModule, ModalModule, PaginationModule, PopoverModule, ProgressbarModule, RatingModule, SortableModule, TabsModule, TimepickerModule.forRoot(), TypeaheadModule.forRoot() ], providers: [AlertConfig, BsDatepickerConfig, BsDropdownConfig, BsModalService, PaginationConfig, ProgressbarConfig, RatingConfig, DraggableItemService, TabsetConfig], bootstrap: [AppComponent] }) export class AppModule { } Update test.component.html to use the timepicker

Ngx-Bootstrap – DatePicker

Ngx-Bootstrap – DatePicker ”; Previous Next ngx-bootstrap DatePicker component is highly configurable and customizable as per our need. It provides various options to select date or date range. BsDatepickerDirective selector [bsDatepicker] Inputs bsConfig − Partial<BsDatepickerConfig>, Config object for datepicker bsValue − Date, Initial value of datepicker container − string, A selector specifying the element the datepicker should be appended to. default: body dateCustomClasses − DatepickerDateCustomClasses[], Date custom classes datesDisabled − Date[], Disable specific dates datesEnabled − Date[], Enable specific dates dateTooltipTexts − DatepickerDateTooltipText[], Date tooltip text daysDisabled − number[], Disable Certain days in the week isDisabled − boolean, Indicates whether datepicker”s content is enabled or not isOpen − boolean, Returns whether or not the datepicker is currently being shown maxDate − boolean, Maximum date which is available for selection minDate − boolean, Minimum date which is available for selection minMode − BsDatepickerViewMode, Minimum view mode : day, month, or year outsideClick − boolean, Close datepicker on outside click, default: true outsideEsc − boolean, Close datepicker on escape click, default: true placement − “top” | “bottom” | “left” | “right”, Placement of a datepicker. Accepts: “top”, “bottom”, “left”, “right”, default: bottom triggers − string, Specifies events that should trigger. Supports a space separated list of event names., default: click Outputs bsValueChange − Emits when datepicker value has been changed onHidden − Emits an event when the datepicker is hidden onShown − Emits an event when the datepicker is shown Methods show() − Opens an element”s datepicker. This is considered a ”manual” triggering of the datepicker. hide() − Closes an element”s datepicker. This is considered a ”manual” triggering of the datepicker. toggle() − Toggles an element”s datepicker. This is considered a ”manual” triggering of the datepicker. setConfig() − Set config for datepicker BsDaterangepickerDirective selector [bsDaterangepicker] Inputs bsConfig − Partial<BsDaterangepickerConfig>, Config object for daterangepicker bsValue − Date, Initial value of daterangepicker container − string, A selector specifying the element the daterangepicker should be appended to. default: body dateCustomClasses − DatepickerDateCustomClasses[], Date custom classes datesDisabled − Date[], Disable specific dates datesEnabled − Date[], Enable specific dates dateTooltipTexts − DatepickerDateTooltipText[], Date tooltip text daysDisabled − number[], Disable Certain days in the week isDisabled − boolean, Indicates whether daterangepicker”s content is enabled or not isOpen − boolean, Returns whether or not the daterangepicker is currently being shown maxDate − boolean, Maximum date which is available for selection minDate − boolean, Minimum date which is available for selection minMode − BsDatepickerViewMode, Minimum view mode : day, month, or year outsideClick − boolean, Close daterangepicker on outside click, default: true outsideEsc − boolean, Close daterangepicker on escape click, default: true placement − “top” | “bottom” | “left” | “right”, Placement of a daterangepicker. Accepts: “top”, “bottom”, “left”, “right”, default: bottom triggers − string, Specifies events that should trigger. Supports a space separated list of event names., default: click Outputs bsValueChange − Emits when daterangepicker value has been changed onHidden − Emits an event when the daterangepicker is hidden onShown − Emits an event when the daterangepicker is shown Methods show() − Opens an element”s datepicker. This is considered a ”manual” triggering of the datepicker. hide() − Closes an element”s datepicker. This is considered a ”manual” triggering of the datepicker. toggle() − Toggles an element”s datepicker. This is considered a ”manual” triggering of the datepicker. setConfig() − Set config for datepicker Example As we”re going to use DatePicker and DateRangePicker, We”ve to update app.module.ts used in ngx-bootstrap Collapse chapter to use BsDatepickerModule and BsDatepickerConfig. Update app.module.ts to use the BsDatepickerModule and BsDatepickerConfig. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule,AlertConfig } from ”ngx-bootstrap/alert”; import { ButtonsModule } from ”ngx-bootstrap/buttons”; import { FormsModule } from ”@angular/forms”; import { CarouselModule } from ”ngx-bootstrap/carousel”; import { CollapseModule } from ”ngx-bootstrap/collapse”; import { BsDatepickerModule, BsDatepickerConfig } from ”ngx-bootstrap/datepicker”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot() ], providers: [AlertConfig, BsDatepickerConfig], bootstrap: [AppComponent] }) export class AppModule { } Update index.html to use the bs-datepicker.css. app.module.ts <!doctype html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>Ngxbootstrap</title> <base href=”/”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <link rel=”icon” type=”image/x-icon” href=”favicon.ico”> <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css” rel=”stylesheet”> <link href=”https://unpkg.com/ngx-bootstrap/datepicker/bs-datepicker.css” rel=”stylesheet” > </head> <body> <app-root></app-root> </body> </html> Update test.component.html to use the datepickers. test.component.html <div class=”row”> <div class=”col-xs-12 col-12 col-md-4 form-group”> <input type=”text” placeholder=”Datepicker” class=”form-control” bsDatepicker [bsValue]=”bsValue” [minDate]=”minDate” [maxDate]=”maxDate” [daysDisabled]=”[6,0]” [datesDisabled]=”disabledDates” [bsConfig]=”{ isAnimated: true, dateInputFormat: ”YYYY-MM-DD” }”> </div> <div class=”col-xs-12 col-12 col-md-4 form-group”> <input type=”text” placeholder=”Daterangepicker” class=”form-control” bsDaterangepicker [(ngModel)]=”bsRangeValue” [datesEnabled]=”enabledDates” [bsConfig]=”{ isAnimated: true }”> </div> </div> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit } from ”@angular/core”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { bsValue = new Date(); bsRangeValue: Date[]; maxDate = new Date(); minDate = new Date(); constructor() { this.minDate.setDate(this.minDate.getDate() – 1); this.maxDate.setDate(this.maxDate.getDate() + 7); this.bsRangeValue = [this.bsValue, this.maxDate]; } ngOnInit(): void { } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200 and verify the following output. Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Tabs

Ngx-Bootstrap – Tabs ”; Previous Next ngx-bootstrap tabs component provides a easy to use and highly configurable Tab component. TabsetComponent selector tabset Inputs justified − boolean, if true tabs fill the container and have a consistent width. type − string, navigation context class: ”tabs” or ”pills”. vertical − if true tabs will be placed vertically. TabDirective selector tab, [tab] Inputs active − boolean, tab active state toggle. customClass − string, if set, will be added to the tab”s class attribute. Multiple classes are supported. disabled − boolean, if true tab can not be activated. heading − string, tab header text. id − string, tab id. The same id with suffix ”-link” will be added to the corresponding element. removable − boolean, if true tab can be removable, additional button will appear. Outputs deselect − fired when tab became inactive, $event:Tab equals to deselected instance of Tab component. removed − fired before tab will be removed, $event:Tab equals to instance of removed tab. selectTab − fired when tab became active, $event:Tab equals to selected instance of Tab component. Example As we”re going to use a Tab, We”ve to update app.module.ts used in ngx-bootstrap Sortable chapter to use TabsModule and TabsetConfig. Update app.module.ts to use the TabsModule and TabsetConfig. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule,AlertConfig } from ”ngx-bootstrap/alert”; import { ButtonsModule } from ”ngx-bootstrap/buttons”; import { FormsModule } from ”@angular/forms”; import { CarouselModule } from ”ngx-bootstrap/carousel”; import { CollapseModule } from ”ngx-bootstrap/collapse”; import { BsDatepickerModule, BsDatepickerConfig } from ”ngx-bootstrap/datepicker”; import { BsDropdownModule,BsDropdownConfig } from ”ngx-bootstrap/dropdown”; import { PaginationModule,PaginationConfig } from ”ngx-bootstrap/pagination”; import { PopoverModule, PopoverConfig } from ”ngx-bootstrap/popover”; import { ProgressbarModule,ProgressbarConfig } from ”ngx-bootstrap/progressbar”; import { RatingModule, RatingConfig } from ”ngx-bootstrap/rating”; import { SortableModule, DraggableItemService } from ”ngx-bootstrap/sortable”; import { TabsModule, TabsetConfig } from ”ngx-bootstrap/tabs”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot(), BsDropdownModule, ModalModule, PaginationModule, PopoverModule, ProgressbarModule, RatingModule, SortableModule, TabsModule ], providers: [AlertConfig, BsDatepickerConfig, BsDropdownConfig, BsModalService, PaginationConfig, ProgressbarConfig, RatingConfig, DraggableItemService, TabsetConfig], bootstrap: [AppComponent] }) export class AppModule { } Update test.component.html to use the tabs component. test.component.html <tabset> <tab heading=”Home”>Home</tab> <tab *ngFor=”let tabz of tabs” [heading]=”tabz.title” [active]=”tabz.active” (selectTab)=”tabz.active = true” [disabled]=”tabz.disabled”> {{tabz?.content}} </tab> </tabset> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit } from ”@angular/core”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { tabs = [ { title: ”First”, content: ”First Tab Content” }, { title: ”Second”, content: ”Second Tab Content”, active: true }, { title: ”Third”, content: ”Third Tab Content”, removable: true }, { title: ”Four”, content: ”Fourth Tab Content”, disabled: true } ]; constructor() {} ngOnInit(): void { } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200. Click on Open modal button and verify the following output. Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Discussion

Discuss Ngx-Bootstrap ”; Previous Next The ngx-bootstrap is a very popular library to use bootstrap components in Angular Based projects. It contains almost all core components of Bootstrap. ngx-bootstrap components are by design modular,extensible and adaptable. Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Modals

Ngx-Bootstrap – Modals ”; Previous Next ngx-bootstrap modal component is a flexible and highly configurable dialog prompt and provides multiple defaults and can be used with minimum code. ModalDirective selector [bsModal] Inputs config − ModalOptions, allows to set modal configuration via element property Outputs onHidden − This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). onHide − This event is fired immediately when the hide instance method has been called. onShow − This event fires immediately when the show instance method is called. onShown − This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). Methods show() − Allows to manually open modal. hide() − Allows to manually close modal. toggle() − Allows to manually toggle modal visibility. showElement() − Show dialog. focusOtherModal() − Events tricks. Example As we”re going to use a modal, We”ve to update app.module.ts used in ngx-bootstrap Dropdowns chapter to use ModalModule and BsModalService. Update app.module.ts to use the ModalModule and BsModalService. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule,AlertConfig } from ”ngx-bootstrap/alert”; import { ButtonsModule } from ”ngx-bootstrap/buttons”; import { FormsModule } from ”@angular/forms”; import { CarouselModule } from ”ngx-bootstrap/carousel”; import { CollapseModule } from ”ngx-bootstrap/collapse”; import { BsDatepickerModule, BsDatepickerConfig } from ”ngx-bootstrap/datepicker”; import { BsDropdownModule,BsDropdownConfig } from ”ngx-bootstrap/dropdown”; import { ModalModule, BsModalService } from ”ngx-bootstrap/modal”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot(), BsDropdownModule, ModalModule ], providers: [AlertConfig, BsDatepickerConfig, BsDropdownConfig,BsModalService], bootstrap: [AppComponent] }) export class AppModule { } Update test.component.html to use the modal. test.component.html <button type=”button” class=”btn btn-primary” (click)=”openModal(template)”>Open modal</button> <ng-template #template> <div class=”modal-header”> <h4 class=”modal-title pull-left”>Modal</h4> <button type=”button” class=”close pull-right” aria-label=”Close” (click)=”modalRef.hide()”> <span aria-hidden=”true”>×</span> </button> </div> <div class=”modal-body”> This is a sample modal dialog box. </div> <div class=”modal-footer”> <button type=”button” class=”btn btn-default” (click)=”modalRef.hide()”>Close</button> </div> </ng-template> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit, TemplateRef } from ”@angular/core”; import { BsModalRef, BsModalService } from ”ngx-bootstrap/modal”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { modalRef: BsModalRef; constructor(private modalService: BsModalService) {} openModal(template: TemplateRef<any>) { this.modalRef = this.modalService.show(template); } ngOnInit(): void { } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200. Click on Open modal button and verify the following output. Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Popover

Ngx-Bootstrap – Popover ”; Previous Next ngx-bootstrap popover component provides a small overlay component to provide small information about a component. PopoverDirective selector popover Inputs adaptivePosition − boolean, sets disable adaptive position. container − string, A selector specifying the element the popover should be appended to. containerClass − string, Css class for popover container delay − number, Delay before showing the tooltip isOpen − boolean, Returns whether or not the popover is currently being shown outsideClick − boolean, Close popover on outside click, default: false placement − “top” | “bottom” | “left” | “right” | “auto” | “top left” | “top right” | “right top” | “right bottom” | “bottom right” | “bottom left” | “left bottom” | “left top”, Placement of a popover. Accepts: “top”, “bottom”, “left”, “right”. popover − string | TemplateRef<any>, Content to be displayed as popover. popoverContext − any, Context to be used if popover is a template. popoverTitle − string, Title of a popover. triggers − string, Specifies events that should trigger. Supports a space separated list of event names. Outputs onHidden − Emits an event when the popover is hidden. onShown − Emits an event when the popover is shown. Methods setAriaDescribedBy() − Set attribute aria-describedBy for element directive and set id for the popover. show() − Opens an element”s popover. This is considered a “manual” triggering of the popover. hide() − Closes an element”s popover. This is considered a “manual” triggering of the popover. toggle() − Toggles an element”s popover. This is considered a “manual” triggering of the popover. Example As we”re going to use a popover, We”ve to update app.module.ts used in ngx-bootstrap Pagination chapter to use PopoverModule and PopoverConfig. Update app.module.ts to use the PopoverModule and PopoverConfig. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule,AlertConfig } from ”ngx-bootstrap/alert”; import { ButtonsModule } from ”ngx-bootstrap/buttons”; import { FormsModule } from ”@angular/forms”; import { CarouselModule } from ”ngx-bootstrap/carousel”; import { CollapseModule } from ”ngx-bootstrap/collapse”; import { BsDatepickerModule, BsDatepickerConfig } from ”ngx-bootstrap/datepicker”; import { BsDropdownModule,BsDropdownConfig } from ”ngx-bootstrap/dropdown”; import { PaginationModule,PaginationConfig } from ”ngx-bootstrap/pagination”; import { PopoverModule, PopoverConfig } from ”ngx-bootstrap/popover”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot(), BsDropdownModule, ModalModule, PaginationModule, PopoverModule ], providers: [AlertConfig, BsDatepickerConfig, BsDropdownConfig, BsModalService, PaginationConfig], bootstrap: [AppComponent] }) export class AppModule { } Update test.component.html to use the modal. test.component.html <button type=”button” class=”btn btn-default btn-primary” popover=”Welcome to Tutorialspoint.” [outsideClick]=”true”> Default Popover </button> <button type=”button” class=”btn btn-default btn-primary” popover=”Welcome to Tutorialspoint.” popoverTitle=”Tutorialspoint” [outsideClick]=”true” placement=”right”> Right Aligned popover </button> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit } from ”@angular/core”; import { BsModalService } from ”ngx-bootstrap/modal”; import { PageChangedEvent } from ”ngx-bootstrap/pagination”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { constructor() {} ngOnInit(): void { } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200. Click on Open modal button and verify the following output. Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Alerts

Ngx-Bootstrap – Alerts ”; Previous Next Alerts provides contextual messages for typical user actions like info, error with available and flexible alert messages. AlertComponent Displays collapsible content panels for presenting information in a limited amount of space. selector alert,bs-alert Inputs dismissible − boolean, If set, displays an inline “Close” button, default: false dismissOnTimeout − string | number, Number in milliseconds, after which alert will be closed isOpen − boolean, Is alert visible, default: true type − string, alert type. Provides one of four bootstrap supported contextual classes: success, info, warning and danger, default: warning Outputs onClose − This event fires immediately after close instance method is called, $event is an instance of Alert component. onClosed − This event fires when alert closed, $event is an instance of Alert component AlertConfig Properties dismissible − boolean, is alerts are dismissible by default, default: false dismissOnTimeout − number, default time before alert will dismiss, default: undefined type − string, default alert type, default: warning Example As we”re going to use alerts, We”ve to update app.module.ts used in ngx-bootstrap Accordion chapter to use AlertModule and AlertConfig. Update app.module.ts to use the AlertModule and AlertConfig. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule, AlertConfig } from ”ngx-bootstrap/alert”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule ], providers: [AlertConfig], bootstrap: [AppComponent] }) export class AppModule { } Update test.component.html to use the alerts. test.component.html <alert type=”success” [dismissible]=”dismissible” [isOpen]=”open” (onClosed)=”log($event)” [dismissOnTimeout]=”timeout”> <h4 class=”alert-heading”>Well done!</h4> <p>Success Message</p> </alert> <alert type=”info”> <strong>Heads up!</strong> Info </alert> <alert type=”warning”> <strong>Warning!</strong> Warning </alert> <alert type=”danger”> <strong>Oh snap!</strong> Error </alert> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit } from ”@angular/core”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { open: boolean = true; dismissible: boolean = true; timeout: number = 10000; constructor() { } ngOnInit(): void { } log(alert){ console.log(”alert message closed”); } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200 and verify the following output. Print Page Previous Next Advertisements ”;

Ngx-Bootstrap – Progressbar

Ngx-Bootstrap – ProgressBar ”; Previous Next ngx-bootstrap progress bar component provides a progress component to show progress of a workflow with flexible bars. ProgressbarComponent selector progressbar Inputs animate − boolean, if true changing value of progress bar will be animated. max − number, maximum total value of progress element. striped − boolean, If true, striped classes are applied. type − ProgressbarType, provide one of the four supported contextual classes: success, info, warning, danger. value − number | any[], current value of progress bar. Could be a number or array of objects like {“value”:15,”type”:”info”,”label”:”15 %”}. Example As we”re going to use a progressbar, We”ve to update app.module.ts used in ngx-bootstrap Popover chapter to use ProgressbarModule and ProgressbarConfig. Update app.module.ts to use the ProgressbarModule and ProgressbarConfig. app.module.ts import { BrowserModule } from ”@angular/platform-browser”; import { NgModule } from ”@angular/core”; import { BrowserAnimationsModule } from ”@angular/platform-browser/animations”; import { AppComponent } from ”./app.component”; import { TestComponent } from ”./test/test.component”; import { AccordionModule } from ”ngx-bootstrap/accordion”; import { AlertModule,AlertConfig } from ”ngx-bootstrap/alert”; import { ButtonsModule } from ”ngx-bootstrap/buttons”; import { FormsModule } from ”@angular/forms”; import { CarouselModule } from ”ngx-bootstrap/carousel”; import { CollapseModule } from ”ngx-bootstrap/collapse”; import { BsDatepickerModule, BsDatepickerConfig } from ”ngx-bootstrap/datepicker”; import { BsDropdownModule,BsDropdownConfig } from ”ngx-bootstrap/dropdown”; import { PaginationModule,PaginationConfig } from ”ngx-bootstrap/pagination”; import { PopoverModule, PopoverConfig } from ”ngx-bootstrap/popover”; import { ProgressbarModule,ProgressbarConfig } from ”ngx-bootstrap/progressbar”; @NgModule({ declarations: [ AppComponent, TestComponent ], imports: [ BrowserAnimationsModule, BrowserModule, AccordionModule, AlertModule, ButtonsModule, FormsModule, CarouselModule, CollapseModule, BsDatepickerModule.forRoot(), BsDropdownModule, ModalModule, PaginationModule, PopoverModule, ProgressbarModule ], providers: [AlertConfig, BsDatepickerConfig, BsDropdownConfig, BsModalService, PaginationConfig, ProgressbarConfig], bootstrap: [AppComponent] }) export class AppModule { } Update test.component.html to use the modal. test.component.html <div class=”row”> <div class=”col-sm-4″> <div class=”mb-2″> <progressbar [value]=”value”></progressbar> </div> </div> <div class=”col-sm-4″> <div class=”mb-2″> <progressbar [value]=”value” type=”warning” [striped]=”true”>{{value}}%</progressbar> </div> </div> <div class=”col-sm-4″> <div class=”mb-2″> <progressbar [value]=”value” type=”danger” [striped]=”true” [animate]=”true” ><i>{{value}} / {{max}}</i></progressbar> </div> </div> </div> Update test.component.ts for corresponding variables and methods. test.component.ts import { Component, OnInit } from ”@angular/core”; @Component({ selector: ”app-test”, templateUrl: ”./test.component.html”, styleUrls: [”./test.component.css”] }) export class TestComponent implements OnInit { max: number = 100; value: number = 25; constructor() {} ngOnInit(): void { } } Build and Serve Run the following command to start the angular server. ng serve Once server is up and running. Open http://localhost:4200. Print Page Previous Next Advertisements ”;