app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
randomNumberInt: number = -1;
generateRandomNumberMax(max: number) {
// Maximum number excluded
this.randomNumberInt = Math.floor(Math.random() * max);
;
}
}
app.component.html
<h2>Angular - Random Whole Number</h2>
<ng-template [ngIf]="randomNumberInt>=0">
Random Number Int: {{randomNumberInt}}
</ng-template>
<br/><br/>
<button
(click)="generateRandomNumberMax(100)"
style="padding:12px;">
Get Random Number
</button>
- angular - How to use ternary operator
- angular - How to generate random number
- angular - Generate random number in range
- angular - How to submit form data
- angular bootstrap - Progressbar maximum value
- angular bootstrap - How to show striped Progressbar
- angular bootstrap - Light & dark Progressbar
- angular bootstrap - Datepicker navigate to current month
- angular bootstrap - Datepicker navigate to specific year month
- angular bootstrap - Datepicker navigate select specific date
- angular bootstrap - How to use Accordion
- angular bootstrap - Open an Accordion panel at a time
- angular bootstrap - Toggle Accordion panel on button click
- angular bootstrap - Disable collapse close Accordion panel
- angular bootstrap - How to use Nav