作者:凌乱LW_502 | 来源:互联网 | 2023-08-29 12:09
角度 ngx 自举计时器组件
原文:https://www . geeksforgeeks . org/angular-ngx-bootstrap-time picker-component/
Angular ngx bootstrap 是一个 bootstrap 框架,与 Angular 一起使用,创建具有很好风格的组件,这个框架非常容易使用,用于制作响应性网站。
在本文中,我们将了解如何在 angular ngx bootstrap 中使用 Timepicker。
安装语法:
npm install ngx-bootstrap --save
进场:
示例:
index.html
" />
"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
rel="stylesheet" />
"https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap"
rel="stylesheet" />
"https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet" />
app.component.html
app.module.ts
import { NgModule } from '@angular/core';
// Importing forms module
import { FormsModule, ReactiveFormsModule }
from '@angular/forms';
import { BrowserModule }
from '@angular/platform-browser';
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { TimepickerModule}
from 'ngx-bootstrap/timepicker';
import { AppComponent }
from './app.component';
@NgModule({
bootstrap: [
AppComponent
],
declarations: [
AppComponent
],
imports: [
FormsModule,
BrowserModule,
BrowserAnimationsModule,
ReactiveFormsModule,
TimepickerModule.forRoot()
]
})
export class AppModule { }
app.component.css
#gfg1 {
margin: 10px;
}
app.component.ts
import { Component, OnInit,LOCALE_ID }
from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
gfg: Date = new Date();
}
输出: