标签: angular-cli

在组件库中找不到 Angular html 文件

我正在为 angular 构建一个组件库,我们将在项目之间共享它。但是当我构建包时,html 文件不会被复制到 dist 文件夹中。我收到错误angular Failed to load text-input.component.html。

这是我的 tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  },
  "exclude": [
    "node_modules",
    "dist",
    "**/*.spec.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

这是编译后的组件:

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) …
Run Code Online (Sandbox Code Playgroud)

angular-template angular-cli angular angular-library

6
推荐指数
1
解决办法
5495
查看次数

Dockerized angular cli 应用程序热重载失败

我已经使用以下设置对我现有的 angular cli 应用程序进行了docker化:

根级dockerfile:

#  Create a new image from the base nodejs 7 image.
FROM node:7
# Create the target directory in the imahge
RUN mkdir -p /usr/src/app
# Set the created directory as the working directory
WORKDIR /usr/src/app
# Copy the package.json inside the working directory
COPY package.json /usr/src/app
# Install required dependencies
RUN npm install
# Copy the client application source files. You can use .dockerignore to exlcude files. Works just as .gitignore does.
COPY . …
Run Code Online (Sandbox Code Playgroud)

docker angular-cli angular

6
推荐指数
1
解决办法
3852
查看次数

Angular 5 背景图片不会显示

我需要帮助。我是一个完整的初学者,我在任何地方都找不到解决方案,很抱歉,如果已经有人问过了,但是无论我尝试什么,我都无法在一页上显示背景图像。

我想做的事?

在主页上显示背景图像。

笔记:

  • 我默认没有资产文件夹。
  • 在本地主机上尝试:4200
  • 在浏览器中转到 Localhost:4200/assets/images/bg.jpg 显示图片。
  • 如果我在 url() 中放置在线托管图像,则一切正常。

由于我的根目录中没有 assets 文件夹,我在 src 文件夹中创建了一个。

结构:

? node_modules
? src
   ? app
      ? components
         ? home
           home.component.html
           home.component.scss
           home.component.spec.ts
           home.component.ts
   ? assets
      ? images
         ? bg.jpg
Run Code Online (Sandbox Code Playgroud)

.angular-cli.json

  "assets": [
    "assets",
    "images",
    "favicon.ico"
  ],
Run Code Online (Sandbox Code Playgroud)

主页.component.scss

.homeBg {
  background-image: url('../../../assets/images/bg.jpg') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  background-size: cover;
  -o-background-size: cover;
  width: 100vw;
  height: 100vh;
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我并告诉我我做错了什么吗?我花了将近 3 个小时试图弄清楚这一点。

提前致谢。

angular-cli angular5

6
推荐指数
1
解决办法
6053
查看次数

如何防止共享模块在 Angular/Webpack 中的延迟加载模块中重复?

所以让我们有以下模块

  1. AppModule - CLI 生成的主模块
  2. 共享模块
  3. 材料模块
  4. CustomModuleA - 延迟加载
  5. CustomModuleB - 延迟加载

现在,SharedModule并MaterialModule加载了 main AppModule。两者都用于CustomModules. 这些惰性模块的捆绑包包含SharedModule并且MaterialModule尽管这 2 个模块已加载到应用程序引导程序中。

有没有办法让“编译器知道”将提供给定的依赖项并且不需要将它包含在给定的包中?(如provided范围 in Maven)

webpack angular-cli angular

6
推荐指数
0
解决办法
180
查看次数

无法卸载 Angular CLI 版本

我一直在尝试使用最新的 CLI 在 Angular6 中创建一个新项目,但一直无法更新。为了解决这个问题,我只是试图删除 Angular CLI 并重新开始,但即使这样也行不通!

从一个随机文件夹(其中没有项目),如果我运行ng -v我得到

Angular CLI: 1.5.4
Node: 9.4.0
OS: darwin x64
Angular:
...
Run Code Online (Sandbox Code Playgroud)

我很容易尝试运行以下命令;

npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli

npm uninstall -g @angular/cli
npm cache verify
Run Code Online (Sandbox Code Playgroud)

然后另一个ng -v,我希望它抱怨没有找到 ng ,而是显示相同的东西!

Angular CLI: 1.5.4
Node: 9.4.0
OS: darwin x64
Angular:
...
Run Code Online (Sandbox Code Playgroud)

我在想这可能与我使用 NVM 来管理我的 Node 版本有关,但我找不到任何东西。

我也试过 npm install -g @angular/cli@latest上述所有内容,但是当我检查我的 ng 版本时,它仍然显示相同的 1.5.4 而不是最新版本。

一些信息;

  1. 我什至不在项目目录中,所以没有 node_modules 并且一切都是全局的 -g
  2. 我在 OSX 上并使用 NVM 来管理我的 Node …

angular-cli angular

6
推荐指数
1
解决办法
3551
查看次数

数据路径“”不应具有附加属性(dryRun)

当我在终端中输入时,我在 MAC 中安装了最新的 Angular 6.0.4:

ng new happiness
Run Code Online (Sandbox Code Playgroud)

展示:

Schematic input does not validate against the Schema: {"dryRun":false,"version":"6.0.4","skipGit":false,"skipInstall":false,"linkCli":false,"commit":true,"newProjectRoot":"projects","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false} Errors:Data path "" should NOT have additional properties(dryRun).
Run Code Online (Sandbox Code Playgroud)

谁能告诉我?非常感谢

macos angular-cli angular

6
推荐指数
1
解决办法
2万
查看次数

角度配置热重载/实时重载以提高速度

我正在使用 Angular 5。

热重载大约需要 8 秒,这是合理的(虽然不是很好)但是有什么方法可以配置它以便我可以调整它以使其更快?

担心随着应用程序的增长它会变得更慢。谢谢。

livereload angular-cli angular hot-reload

6
推荐指数
1
解决办法
7933
查看次数

使用不同的环境设置运行 ng build --prod

我为每个客户都有不同的环境设置,每个客户都有自己的 {{custName}}/environment.prod.ts 文件。我想通过 ng build --prod 命令使用它们各自的 prod 环境文件。我面临的问题是即使在指定环境之后它使用默认的 environment.prod.ts

我的package.json有类似的脚本

{.....
   customer_a : "ng build --prod --environment=custA_prod",
....}
Run Code Online (Sandbox Code Playgroud)

在angular-cli.json我已经提到了这样的路径

  "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts",
        "qa": "environments/environment.qa.ts",
        "custA_prod": "environments/custA/environment.prod.ts"
}
Run Code Online (Sandbox Code Playgroud)

是否可以使用 prod build 的所有功能但具有一些不同的环境设置?

build production-environment package.json angular-cli angular

6
推荐指数
2
解决办法
1万
查看次数

即使我使用目标 esm2015,ivy 也编译为 esm5 模块

@angular 常春藤问题

描述

当我使用 ng cli 时,它将模块编译为 esm2015,我的问题是我有一个旧系统,因为 angular 2 次,我使用 webpack,但对我来说它编译为 es5。

如何更改它以编译为 esm2015?

最小复制

我的 tsconfig.aot.json:

{
    "compilerOptions": {
        "rootDir": ".",
        "baseUrl": ".",
        "skipLibCheck": true,
        "outDir": "build/aot",
        "target": "es2015",
        "module": "esnext",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true,
        "lib": [
            "es2018",
            "dom"
        ],
        "paths": {
            "corifeus-web-material": [
                "build-modules/corifeus-web-material/index.ts"
            ],
            "corifeus-web": [
                "build-modules/corifeus-web/index.ts"
            ],
            "corifeus-web-material/*": [
                "build-modules/corifeus-web-material/*"
            ],
            "corifeus-web/*": [
                "build-modules/corifeus-web/*"
            ]
        }
    },
    "include": [
        "build-modules/**/*",
        "src/angular/**/*",
        "test/angular-webpack/**/*"
    ],
    "exclude": [
        "src-save",
        "*.worker.js", …
Run Code Online (Sandbox Code Playgroud)

angular-cli

6
推荐指数
2
解决办法
2万
查看次数

如何将 i18n 与作为 Angular 对象的组件输入一起使用?

有一种情况在子组件上定义输入,如下所示:

interface MyValues {
   text: string;
   path: string;
   someOtherValue: string;
}

@Input() myValues: MyValues;
Run Code Online (Sandbox Code Playgroud)

我需要myValues通过如下输入从父组件传递给子组件:

<my-child-component [myValues]="myValues" />
Run Code Online (Sandbox Code Playgroud)

由于它不是简单的数据类型输入,因此我无法使用此处Angular 文档中推荐的 i18n 属性样式。这是一个具有多个值的对象,因此在传递给子组件时无法对其进行翻译(除非我遗漏了某些东西)。

在子组件中,有一些代码如下:

<span *ngFor="let myValue of myValues">
   <a>{{myValue.Text}}</a>
</span>
Run Code Online (Sandbox Code Playgroud)

通常我想做的是为需要翻译的锚点分配一个 id,如下所示:

<a i18n="@@myChildComponent_text">{{myValue.Text}}</a>
Run Code Online (Sandbox Code Playgroud)

这样做的问题是它会在名为的翻译文件中创建一个字段,@@myChildComponent_text以进行翻译。但是,传递给这个子组件的这个对象在里面的值是动态的myValues,因此字面翻译将根据传入的内容而变化。

我的问题是,在将对象传递给子组件上的输入时,我如何仍然利用i18nAngular 国际化能力和@@id自定义 id,该对象将在其中具有需要转换的不同物理值?

internationalization angular-cli angular-i18n angular

6
推荐指数
1
解决办法
6201
查看次数