标签: angular8

在 Angular 8 中在 Facebook 上共享链接时更新的元数据未显示

我正在使用 Angular 的 addTag() 和 updateTag() 更新 Angular 8 网站的元数据以获取动态内容。这些函数会更新元数据(og:description、og:image、og:title 等),正如我在检查部分中看到的那样,但当我在 Facebook 上共享它时,它不会显示更新的元数据。任何人都可以帮我解决这个问题吗?我也尝试过 Angular Universal,但这也不起作用。

angular angular8

5
推荐指数
0
解决办法
274
查看次数

Angular订阅表单组中表单数组中的值变化

我是 angular8,我在表单组内有一个表单数组,但我想检测某个输入的新更改。

ngOnInit(): void {
    this.makeForm = this.fb.group({

     
      
      year:['', Validators.required],
      amount:['', Validators.required],
      desc:['', Validators.required],
      details: new FormArray([
        this.det(), 
      ])
    })


det(){
      return new FormGroup({
        requestfor     : new FormControl(''),
        remarks        : new FormControl('')
    })}


Run Code Online (Sandbox Code Playgroud)

我必须检查 formarray 值中每个值发生变化的数据。但如果我使用,我会收到错误

this.makeForm.value.details.get('requestfor').valueChanges

Run Code Online (Sandbox Code Playgroud)

错误是

ERROR TypeError: Cannot read property 'valueChanges' of undefined
Run Code Online (Sandbox Code Playgroud)

如何获取表单数组值内的值

如何获取该值......

angular angular-reactive-forms angular-forms angular-formbuilder angular8

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

从 8 更新到 Angular 11 时出错:无法解析 '/Users/foo/node_modules/request' 中的 'util'

我正在对我的 Angular 8 项目 \xe2\x86\x92 Angular 11 进行重大更新。

\n

我很好地遵循了https://update.angular.io/?l=3&v=8.2-11.0的步骤。

\n

我的项目中有一些软件包似乎与 v.^11 不兼容,因此我使用以下命令安装了这些软件包

\n
npm install --legacy-peer-deps\n
Run Code Online (Sandbox Code Playgroud)\n

当我尝试使用 提供内容时ng serve,我收到大量无法解析“util”和无法解析“zlib”消息。例如,

\n
\n

错误:/Users/mf/node_modules/snapdragon/lib/parser.js 找不到模块:错误:无法解析\n\'/Users/mf/node_modules/snapdragon/lib\'中的\'util\'

\n

错误:/Users/mf/node_modules/sshpk/lib/certificate.js 未找到模块:错误:无法解析\n\'/Users/mf/node_modules/sshpk/lib\'中的\'util\'

\n

错误:/Users/mf/node_modules/sshpk/lib/private-key.js 未找到模块:错误:无法解析\n\'/Users/mf/node_modules/sshpk/lib 中的\'util\' \'

\n

错误:/Users/mf/node_modules/sshpk/lib/errors.js 找不到模块:\n错误:无法解析 \'/Users/mf/node_modules/sshpk/lib\' 中的 \'util\'

\n

错误:/Users/mf/node_modules/sshpk/lib/ed-compat.js 找不到模块:\n错误:无法解析 \'/Users/mf/node_modules/sshpk/lib\' 中的 \'util\'

\n

错误:/Users/mf/node_modules/sshpk/lib/identity.js 找不到模块:\n错误:无法解析 \'/Users/mf/node_modules/sshpk/lib\' 中的 \'util\'

\n

错误:/Users/mf/node_modules/static-extend/index.js 找不到模块:\n错误:无法解析 \'/Users/mf/node_modules/static-extend\' 中的 \'util\'

\n

错误:/Users/mf/node_modules/through2/through2.js 找不到模块:\n错误:无法解析 \'/Users/mf/node_modules/through2\' 中的 \'util\'

\n

错误:/Users/mf/node_modules/tough-cookie/lib/memstore.js 未找到模块:错误:无法解析\n\'/Users/mf/node_modules/tough-cookie 中的\'util\' /lib\'

\n

错误:/Users/mf/node_modules/tunnel-agent/index.js 找不到模块:\n错误:无法解析 \'/Users/mf/node_modules/tunnel-agent\' 中的 \'util\'

\n

0mError: …

npm webpack angular angular8 angular11

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

Angular 8 中的 ngx-useful-swiper 设置出现错误

我按照指南在我的 Angular 8 应用程序中设置了滑动滑块。

将NgxUsefulSwiperModule导入app.module.ts时出现以下错误

./node_modules/ngx-useful-swiper/fesm2015/ngx-useful-swiper.js 中的错误未找到模块:错误:无法解析“C:\Users\Dan\NewAngular\node_modules\ngx”中的“swiper/bundle” -有用的swiper\fesm2015'

我尝试删除 node_modules 文件夹并重新安装所有内容,但每次都失败。

有人可以告诉我我做错了什么吗?

这是我的 package.json 文件

{
  "name": "angular",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --ssl",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "run:prod": "ng build --prod",
    "test-single-run": "ng test --watch=false"
  },
  "private": true,
  "dependencies": {
    "@aleesaan/ng-scrollspy": "^1.0.2",
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/pwa": "^0.1000.0", …
Run Code Online (Sandbox Code Playgroud)

angular angular8 ngx-swiper-wrapper swiper.js

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

角度材料日期验证未按预期进行

我正在研究mat-datepicker用户可以输入值并使用我的代码选择日期的位置它工作正常。我有一个更新按钮,默认情况下它将处于禁用模式。当用户满足两个条件时,只有更新按钮才会启用。

这是我的屏幕截图,它看起来像

在此输入图像描述

如果我清除最后日期,则一旦用户输入最后日期,更新按钮将处于禁用模式,那么只有更新将在此处启用我遇到了问题

这是我的 ts 代码

dateValidator(input) {
    //console.log(input);
    console.log(Object.prototype.toString.call(input) === '[object Date]', !this.disableDate(), input.length > 0)
    if (!!input) { // null check
        if (Object.prototype.toString.call(input) === '[object Date]' && !this.disableDate() && input.length > 0) {
            this.disableUpdateBtn = false;
            console.log("Date is Valid!!");
        } else {
        this.disableUpdateBtn = true;
        console.log("Date is Invalid!!");
        }
    } else {
        this.disableUpdateBtn = true;
        console.log("Date is Invalid!!");
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的HTML“更新”按钮的代码

<button mat-flat-button color="primary" (click)="updateMilestone();" cdkFocusInitial [disabled]="disableUpdateBtn">
    Update
</button>
Run Code Online (Sandbox Code Playgroud)

当我单击清除按钮,然后开始输入日期,然后输入 时,出现错误01。我没有收到任何错误,但是当我开始输入 …

angular-material angular angular8 mat-datepicker

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

新 loadChildren 导入语法中的 Angular 8 延迟加载模块未被延迟加载

我最近将一个项目升级到 Angular 8,我尝试将 loadChildren 导入切换到新语法

例如来自:

loadChildren: './maintenance/maintenance.module#MaintenanceModule',
Run Code Online (Sandbox Code Playgroud)

到:

loadChildren:() => import('./maintenance/maintenance.module').then(m => m.MaintenanceModule),
Run Code Online (Sandbox Code Playgroud)

应用程序路由是这样创建的:

@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes, {
      scrollPositionRestoration: 'enabled',
      enableTracing: false,
    }),
  ],
  exports: [RouterModule],
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)

然而,在构建项目时,似乎没有模块被延迟加载。使用 Webpack 包分析器,我可以看到所有路由模块都包含在主包中,并且导航到这些路由时也没有发生网络活动。

有人知道我在这里缺少什么吗?

angular angular8

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

Angular 8 ngx-bootstrap modal No component factory found

I have a module which looks something like:

@NgModule({
  imports: [
    EmployeeRoutingModule,
  ],
  declarations: [
    ListEmployeeComponent,
    EmployeeDialogComponent,
  ],
  providers: [
    EmployeeService,
    BsModalService,
  ],
  entryComponents: [
    EmployeeDialogComponent,
  ]
})
export class EmployeeModule {
}
Run Code Online (Sandbox Code Playgroud)

And it is imported into the app module like so

{
  path: 'employee',
  loadChildren: './employee/employee.module#EmployeeModule'
},
Run Code Online (Sandbox Code Playgroud)

within the app.routing.ts.

When I try and use EmployeeDialogComponent in my EmployeeModule it keeps giving off the error

ERROR Error: No component factory found for EmployeeDialogComponent. Did you add it …
Run Code Online (Sandbox Code Playgroud)

ngx-bootstrap angular angular8

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

更新到Angular 8 CLI后,抛出“ .getColorDepth不是函数”

我的一个同事将我们的项目升级到8号角。我拉了他的分支,然后奔跑npm install。在他的分支上,一切正常。现在,每次运行任何“ ng ...”命令时,我都会得到相同的错误:

C:\xxx\party-ui\node_modules\@angular\cli\utilities\color.js:15
    process.stdout.getColorDepth() > 1;
                   ^

    TypeError: process.stdout.getColorDepth is not a function
        at Object.<anonymous> (C:\xxx\party-ui\node_modules\@angular\cli\utilities\color.js:15:20)
        at Module._compile (module.js:652:30)
        at Object.Module._extensions..js (module.js:663:10)
        at Module.load (module.js:565:32)
        at tryModuleLoad (module.js:505:12)
        at Function.Module._load (module.js:497:3)
        at Module.require (module.js:596:17)
        at require (internal/module.js:11:18)
        at Object.<anonymous> (C:\xxx\party-ui\node_modules\@angular\cli\models\analytics.js:18:17)
        at Module._compile (module.js:652:30)
Run Code Online (Sandbox Code Playgroud)

我还尝试更新npm和node(现在具有版本10.16.0和6.9.0)。还删除了node_modules文件夹,然后运行npm install。我能做什么?

node.js typescript angular angular8

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

尝试通过ng update升级到Angular Material 8时,获得了@ angular / *版本〜9.0.0-next-0。为什么会有这种差异?

我正在尝试使用此处的说明将Angular 7应用程序升级到Angular 8 。一切顺利,直到最后一步:

ng更新@ angular / material

这将Angular Material软件包更新为8.1.2,但也将@ angular / *软件包升级为一个相当奇怪的不需要的版本:〜9.0.0-next.0

Angular Material 7-> 8升级效果

这是有问题的(我不得不摆脱一个非必需的dev依赖关系,该依赖关系要求Angular <= 8),因为我不想超越最新的稳定版本8

我该如何解决?

angular angular8 angular-material-8

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

如何在有角度的Web Worker内导入节点模块?

我尝试在Angular 8 Web Worker内导入节点模块,但出现编译错误“找不到模块”。有人知道如何解决吗?

我在的电子项目中使用创建了一个新工作人员ng generate web-worker app,如上述ng文档中所述。

一切正常,直到我添加一些导入,例如pathfs-extra

/// <reference lib="webworker" />    
import * as path from 'path';

addEventListener('message', ({ data }) => {    
  console.log(path.resolve('/'))
  const response = `worker response to ${data}`;
  postMessage(response);
});
Run Code Online (Sandbox Code Playgroud)

这种导入在任何其他ts组件中都可以正常工作,但是在Web Worker中,我收到此消息的编译错误,例如

Error: app/app.worker.ts:3:23 - error TS2307: Cannot find module 'path'.
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?也许我需要在生成一些其他参数tsconfig.worker.json

重现该错误,请运行:

$ git clone https://github.com/hoefling/stackoverflow-57774039
$ cd stackoverflow-57774039
$ yarn build
Run Code Online (Sandbox Code Playgroud)

或在Travis上查看项目的构建日志

注意:

1)我只发现是一个类似的问题,但答案仅处理自定义模块。

2)我使用 …

web-worker node.js typescript angular angular8

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