app.component.ts
import { Component } from '@angular/core';
import { NgbCalendar, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
//model:NgbDateStruct;
model:any;
isDisabled:boolean = true;
constructor(private calendar: NgbCalendar) {}
onClick(){
this.isDisabled = !this.isDisabled
}
}
app.component.html
<h4 style="padding-top:25px; padding-bottom:25px;">
Angular Bootstrap - Enable Disable Datepicker
</h4>
<h5><b>Selected Date:</b></h5>
<h5>{{ model | json }}</h5>
<br/>
<ngb-datepicker
#datePicker
[(ngModel)]="model"
[disabled]="isDisabled">
</ngb-datepicker>
<br/><br/>
<button (click)="onClick()">
{{isDisabled? 'Enable Datepicker' : 'Disable Datepicker'}}
</button>
- angular - How to use if then condition
- angular - How to use if statement
- angular - Multiple condition
- angular - Loop through an array of objects
- angular bootstrap - How to use Collapse
- angular bootstrap - How to use Rating
- angular bootstrap - Popover with HTML content
- angular bootstrap - How to delay Popover open close
- angular bootstrap - Show multiple months in a Datepicker
- angular bootstrap - Select date range in a Datepicker
- angular bootstrap - Select date range from Datepicker popup
- angular bootstrap - Datepicker custom day style
- angular bootstrap - Select Nav tab on button click
- angular bootstrap - Prevent selecting a tab in Nav
- angular bootstrap - How to enable disable tab in Nav