【问题标题】:Accessing files outside project folder访问项目文件夹外的文件
【发布时间】:2018-06-01 11:31:33
【问题描述】:

我正在开发一个 Angular 5 应用程序,我在访问某些文件时遇到了一些问题。让我向您展示我的项目是如何设置的,以便您查看问题。

    • desired_files
    • angularApp
    • app_generating_files

所以我的问题是我需要能够从我的 Angular 应用程序访问 desired_filesfolder 中的文件。进入这个文件夹的文件也是由我的根目录中的另一个项目生成的。如果您对我如何做到这一点有任何想法,我们将不胜感激。

(我在 app_generating_files 项目中使用 Docker,所以我不确定尝试使用它是否是个好主意)

【问题讨论】:

    标签: angular docker directory


    【解决方案1】:

    您正在寻找的答案的开始在这里:Angular-cli: How can I access images outside of the assets folder

    在glob对象中,一定要加上allowOutsideOutDir

    {
      "glob": "**/*",
      "input": "../../path/to/files",
      "output": "./assets/outside-assets",
      "allowOutsideOutDir": true
    }

    例如,如果您在目录“../../path/to/files”中有一个名为 test.jpg 的图像,您可以使用标记将其包含在您的项目中 p>

    <img src="assets/outside-assets/test.jpg" alt="not found">
    

    确保您的 ng-cli 的本地版本是 1.5.0,因为较新的版本不支持 allowOutsideOutDir,正如此处所讨论的 https://github.com/angular/angular-cli/issues/8783

    【讨论】:

    • 这个绑定是运行时还是编译时?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-28
    • 2015-07-01
    相关资源
    最近更新 更多