安装ngx-device-detector之后无法编译
创始人
2024-08-30 01:30:08
0

在使用ngx-device-detector时,需要在app.module.ts中导入DeviceDetectorModule,并将其添加到@NgModule的imports数组中。

示例代码:

  1. 安装ngx-device-detector:

    npm install ngx-device-detector --save

  2. 在app.module.ts中导入DeviceDetectorModule,并将其添加到@NgModule的imports数组中:

    import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { DeviceDetectorModule } from 'ngx-device-detector';

    @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DeviceDetectorModule.forRoot() ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }

  3. 在组件中使用DeviceService:

    import { Component } from '@angular/core'; import { DeviceDetectorService } from 'ngx-device-detector';

    @Component({ selector: 'app-component', template:

    {{deviceInfo.device}}
    }) export class AppComponent { deviceInfo = null;

    constructor(private deviceService: DeviceDetectorService) {
        this.deviceInfo = this.deviceService.getDeviceInfo();
    }
    

    }

相关内容

热门资讯

玩家必看科普!wepoker轻... 玩家必看科普!wepoker轻量版透视方法,拱趴大菠萝自动计算机器人,新2025教程(有挂攻略)准备...
科普常识!佛手大菠萝有挂吗,w... 科普常识!佛手大菠萝有挂吗,wepoker辅助透视,分享教程(有挂透视);佛手大菠萝有挂吗软件透明挂...
推荐十款!wepoker软件安... 推荐十款!wepoker软件安装包,wepokerplus辅助,可靠教程(有挂透明);支持多人共享记...
关于!wejoker辅助器怎么... 关于!wejoker辅助器怎么卖,hhpoker是内部控制吗,2025新版技巧(有挂透视)1、很好的...
技术分享!wepoker私人局... 这是一款非常优秀的wepoker私人局透视插件 ia辅助检测软件,能够让你了解到wepoker私人局...
指导大家!pokemmo手机辅... 指导大家!pokemmo手机辅助软件,hhpoker有没有作弊辅助,系统教程(有挂方法)1、很好的工...
科技通报!拱趴大菠萝万能挂,w... 科技通报!拱趴大菠萝万能挂,wepoker-h5下载,AI教程(有挂技巧)1、点击下载安装,微扑克w...
玩家攻略!wepoker辅助器... 1、玩家攻略!wepoker辅助器安装包,wepoker俱乐部辅助器,细节揭秘(有挂攻略)(UU p...
一分钟揭秘!大菠萝免费辅助,w... 一分钟揭秘!大菠萝免费辅助,wepoker免费透视,新版2025教程(有挂教程);支持2-10人实时...
必备辅助推荐!hhpoker免... 《必备辅助推荐!hhpoker免费透视脚本,pokemomo辅助工具,详细教程(有挂软件)》 hhp...