ngx loader indicator
v1.11.0
ตัวบ่งชี้ตัวโหลด NGX เป็นคำสั่งที่ดีที่สุดที่จะมีโหลดเดอร์โดยไม่ต้องห่อองค์ประกอบของคุณลงในส่วนประกอบเพิ่มเติม

คุณสามารถลองใช้หน้ากาก NGX ของเราตรวจสอบได้ คุณสามารถลองใช้ ngx copypaste ของเราตรวจสอบได้
$ npm install --save ngx-loader-indicatorให้ความสนใจเวอร์ชันนี้ใช้งานได้สำหรับ Angular> = 14.0.0
กำหนดค่าสำหรับแอปพลิเคชันด้วย provideEnvironmentNgxLoaderIndicator
bootstrapApplication ( AppComponent , {
providers : [
provideAnimations ( ) ,
provideEnvironmentNgxLoaderIndicator ( ) ,
( ... )
] ,
} ) . catch ( ( err ) => console . error ( err ) ) ; หรือกำหนดค่าสำหรับคุณสมบัติที่มี provideNgxLoaderIndicator และนำเข้า directive NgxLoaderIndicatorDirective นำเข้า
@ Component ( {
selector : 'my-feature' ,
templateUrl : './my-feature.component.html' ,
styleUrls : [ './my-feature.component.css' ] ,
standalone : true ,
imports : [ NgxLoaderIndicatorDirective , ( ... ) ] ,
providers : [
( ... )
provideNgxLoaderIndicator ( {
img : 'https://avatars2.githubusercontent.com/u/32452610?s=200&v=4' ,
loaderStyles : {
background : 'rgba(255, 255, 255, 0.8)' ,
} ,
imgStyles : {
width : '50px' ,
background : 'yellow' ,
} ,
rotate : {
duration : 5000 ,
} ,
} ) ,
] ,
} )
export class MyFeatureComponent { } ให้ความสนใจเวอร์ชันนี้ใช้งานได้สำหรับ Angular <12.0.0
นำเข้าโมดูลในโมดูลที่จำเป็น
import { NgxLoaderIndicatorModule } from 'ngx-loader-indicator'
( ... )
@ NgModule ( {
( ... )
imports : [
NgxLoaderIndicatorModule . forRoot ( options )
]
( ... )
} ) < div [ngxLoaderIndicator] =" isLoading " > Content </ div > < form (ngSubmit) =" save(form.value) " [formGroup] =" form " [ngxLoaderIndicator] =" isLoading " >
< h2 > Login </ h2 >
< input matInput type =" email " placeholder =" Email " #email formControlName =" email " />
< input matInput type =" password " placeholder =" Password " #name formControlName =" password " />
< button mat-button [disabled] =" form.invalid " > Login </ button >
</ form > คุณสามารถกำหนดตัวเลือกที่กำหนดเองของคุณ
{
img : string ,
imgStyles : {
width : string , // '30px'
background : string , // 'yellow' or rgb(255, 255, 0)
}
} {
loaderStyles : {
background : string ,
} ,
} rotate: {
delay ?: number ;
direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse' ;
duration: number
easing?: string ;
endDelay?: number ;
fill?: 'none' | 'forwards' | 'backwards' | 'both' | 'auto' ;
id?: string ;
iterationStart?: number ;
iterations?: number ;
} , import { NgxLoaderIndicatorModule } from 'ngx-loader-indicator'
( ... )
@ NgModule ( {
( ... )
imports : [
NgxLoaderIndicatorModule . forRoot ( {
img : 'https://avatars2.githubusercontent.com/u/32452610?s=200&v=4' ,
loaderStyles : {
background : 'rgba(255, 255, 255, 0.8)' ,
} ,
imgStyles : {
width : '100px' ,
background : 'yellow' ,
} ,
rotate : {
duration : 5000
} ,
} ) ,
]
( ... )
} )