小编ben*_*oam的帖子

加载同一模块的多个路径 - 延迟加载

我在一个模块中有多个组件。我想根据路由路径显示组件。对于http://localhost:4200/account我想显示帐户组件。对于http://localhost:4200/setting我想显示设置组件 ..etc

app.routing.module.ts

{
    path: 'account',
    loadChildren: './modules/settings/settings.module#SettingsModule',
},
{
    path: 'settings',
    loadChildren:'./modules/settings/settings.module#SettingsModule', 
},
Run Code Online (Sandbox Code Playgroud)

settings.routing.module.ts

export const routes: Routes = [
    {
        path: 'account',
        component: accountComponent
    },
    {
        path: 'account/edit',
        component: accountEditComponent
    },
    {
        path: 'settings',
        component: settingsComponent
    },
    {
        path: 'settings/edit',
        component: settingsEditComponent
    }
];
Run Code Online (Sandbox Code Playgroud)

我在 settings.routing.module.ts 中做了哪些更改以显示这些组件。

angular angular-router

9
推荐指数
1
解决办法
3252
查看次数

无法设置 fileReplacements 以使用 Angular 11 替换文件夹内容

我使用angular.jsonfileReplacements文件中的Angular cli 配置来替换文件夹内容,如下所示:

{
  "projects": {
    "myProject": {
      "architect": {
        "build": {
          "configurations": {
            "prod": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                },
                {
                  "replace": "node_modules/moment/locale/",
                  "with": "src/moment-js-locale/"
                }
              ]
            }
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

请注意,在replace值中我使用的是文件夹路径而不是文件路径。这是 Angular 10 的工作代码。

我升级到 Angular 11,现在尝试使用以下命令构建产品版本时遇到错误: ng build --prod

我收到的错误是:

Schema validation failed with the following errors:
  Data path ".fileReplacements[1]" should NOT have additional properties(replace).
  Data path ".fileReplacements[1].replace" should match pattern "\.(([cm]?j|t)sx?|json)$".
  Data path ".fileReplacements[1]" should …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular angular-json angular11

8
推荐指数
1
解决办法
9299
查看次数

我可以直接从chrome DevTools编辑我的角度项目的CSS文件吗?

使用默认视图封装(模拟)在浏览器开发工具中为组件设置样式的最有效方法是什么?

我当前的工作流程涉及从开发工具中进行大量繁琐的复制和粘贴,如下所示:

在此输入图像描述

Chrome开发工具能够将DOM上的样式更改保存到源css文件(使用工作区保存更改到磁盘),但我不知道这是否适用于Angular和Webpack使用模拟组件样式的方式.

必须有比我目前更快的工作流程.有小费吗?

css google-chrome-devtools visual-studio-code angular-cli angular

5
推荐指数
1
解决办法
759
查看次数

Angular 6.x 在 IE 11 中不起作用 - 错误:参数无效

我有一个在 Chrome 中完美运行的 Angular 6.x 应用程序。问题是尝试在 IE 11 中运行它时,出现错误:

错误:无效的参数。在 DefaultDomRenderer2.prototype.setProperty...

在此处输入图片说明

已经在 StackOverflow 中尝试了我在没有帮助的情况下找到的所有答案。我在这里列出主题,所以你们不会尝试将它们作为答案:

感谢您的帮助。

internet-explorer polyfills internet-explorer-11 angular angular6

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