npm install ngx-device-detector --save
export class AppComponent implements OnInit {
isChrome: boolean;
isFirefox: boolean;
private readonly _deviceDetectorService = inject(DeviceDetectorService);
ngOnInit() {
const browser = this.deviceService.browser;
this.isChrome = browser === 'Chrome';
this.isFirefox = browser === 'Firefox';
console.log(`Is Chrome: ${this.isChrome}`);
console.log(`Is Firefox: ${this.isFirefox}`);
}
}
export class AppComponent implements OnInit {
isChrome: boolean;
isFirefox: boolean;
constructor(private deviceService: DeviceDetectorService) {}
ngOnInit() {
const browser = this.deviceService.browser;
this.isChrome = browser === 'Chrome';
this.isFirefox = browser === 'Firefox';
console.log(`Is Chrome: ${this.isChrome}`);
console.log(`Is Firefox: ${this.isFirefox}`);
}
}