angular – 如何在网关项目中添加外部JavaScript库

前端之家收集整理的这篇文章主要介绍了angular – 如何在网关项目中添加外部JavaScript库前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图将 Simpl5 javascript库添加到我的网关失败.
我把SIPml-api.js和SIPml.js放在webapp / content / scripts文件夹中.

在.angular-cli.json我更新了脚本数组,如下所示:

"scripts": [
        "content/scripts/SIPml-api.js","content/scripts/SIPml.js"
    ]

然后我尝试在组件中调用SIPml,如下所示:

import { Component,OnInit } from '@angular/core';
declare var SIPml: any;

.

ngOnInit() {
    SIPml.setDebugLevel((window.localStorage && window.localStorage.getItem('org.doubango.expert.disable_debug') === 'true') ? 'error' : 'info');

}

我收到ERROR ReferenceError:控制台中未定义SIPml.

有人可以帮忙吗?

解决方法

JHipster并没有像@GaëlMarzIoU评论中提到的那样完全支持角度cli.

The original idea of supporting the CLI was only for code generation.

所以任何.angular-cli.json修改都没有任何效果,因为JHipster使用自己的构建/服务链(查看package.json自定义脚本,它们不是基于ng服务/构建等)检查this issue discussion了解更多详情.

您需要在vendor.ts中引用自定义css和js然后当您运行npm run serve时,您将看到结果.

猜你在找的Angularjs相关文章