【问题标题】:material.svgAssetsCache injected in module of application - angular js在应用程序模块中注入的material.svgAssetsCache - angular js
【发布时间】:2016-11-29 16:20:07
【问题描述】:

我想知道为什么将模块material.svgAssetsCache 注入到Angular 材料网站上使用的代码中。

angular.module('MyApp',['ngMaterial', 'ngMessages', 'material.svgAssetsCache'])

这是 AM 网站上的代码示例:https://material.angularjs.org/latest/demo/button

我知道该应用程序使用 svgs 作为图标,但它仍然可以在不注入 material.svgAssetsCache 库的情况下工作。

【问题讨论】:

  • 不注入它不起作用 - codepen.io/camden-kid/pen/QEAZNo
  • 谢谢@camden_kid。当我将文件直接包含在 img 文件夹中时,我看不出有什么区别。由于您的代码没有 img 文件夹,因此它使用 js 文件中的文件。
  • 应该接受以下答案吗?

标签: angularjs svg angular-material


【解决方案1】:

根据Angular Material repository 中的评论,该文件只能在CDN Server 或Edge Server 中使用:

/**
  * This 'svg-assets-cache.js' file should be loaded to a CDN or edge-server (currently S3).
  * The CDN url (for this file) is then used in `doc/app/js/codepen.js#L59` to identify an
  * external JS file that CodePen should load for 'launched' demos.
  */

所以,最后你是对的。如果您自己托管材料图标,则不需要包含它。它仅适用于 CodePen。

【讨论】:

    猜你喜欢
    • 2017-07-30
    • 2020-08-02
    • 2014-04-21
    • 2016-05-30
    • 2013-07-30
    • 1970-01-01
    • 2020-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多