标签: angular5

如何自定义 ngx-bootstrap 日期选择器

我想自定义 ngx-bootstrap datepicker 弹出窗口。基本上我想在显示日期的日历中添加链接/按钮,点击该日期将被添加到日期选择器字段。

我找不到任何自定义日期选择器的方法。我正在使用 Angular 5 和 ngx-bootstrap:https ://valor-software.com/ngx-bootstrap/#/datepicker

提前致谢。

customization datepicker ngx-bootstrap angular angular5

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

Angular 5+ 构造函数字段注入器错误

所以我不是简单地尝试使用像这样的构造函数初始化一些字段来注入服务。

  constructor(private wheels : number, private model : string, private automatic : boolean, private colour : string, private engine : string, private seats :number) { 
    this.wheels = wheels;
    this.model = model;
    this.automatic = automatic;
    this.colour = colour;
    this.engine = engine;
    this.seats = seats;
  }
Run Code Online (Sandbox Code Playgroud)

如果我现在创建一个新对象,然后在 console.log 中创建一个包含所有初始化值的对象,我已经在没有 this.x=x 的情况下尝试过它,但是该项目不会加载并给我这个错误消息。

ERROR Error: StaticInjectorError(AppModule)[Module1AComponent -> Number]: 
  StaticInjectorError(Platform: core)[Module1AComponent -> Number]: 
    NullInjectorError: No provider for Number!
    at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1034)
    at resolveToken (core.js:1271)
    at tryResolveToken (core.js:1216)
    at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1113)
    at resolveToken (core.js:1271)
    at tryResolveToken …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular angular5

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

错误 TS2355:声明类型既不是“void”也不是“any”的函数必须返回一个值

我在 angular 5 中使用身份验证保护来检查用户是否应该能够导航到特定页面。我收到与返回 observable 相关的错误:

声明类型既不是“void”也不是“any”的函数必须返回一个值。

这是我的 authguard.ts

从“@angular/core”导入{可注射};从 '@angular/router' 导入 { Router, CanActivate, ActivatedRoute, ActivatedRouteSnapshot, RouterStateSnapshot }; 从'../../service/application-verification.service'导入{ApplicationVerificationService};

@Injectable() export class AppStatusGuard implements CanActivate {

  applicationId: number;   personId: number;

  constructor(
    public router: Router,
    public readonly activeRoute: ActivatedRoute,
    public readonly applicationVerificationService: ApplicationVerificationService) { }

  loginRoute: boolean;   memberRoute: boolean;


  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {

    this.applicationId = Number(route.params["applicationId"]);
    this.personId = Number(route.params["personId"]);

    // Make sure they are allowed on this page, if not re-direct
    const url = this.applicationVerificationService.getRouteForFellowshipApplicant(this.personId, this.applicationId)
      .subscribe((res: string) …
Run Code Online (Sandbox Code Playgroud)

subscribe rxjs typescript angular angular5

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

index.html 中的条件视口元标记

我有一个带有两个子模块的 angular 模块,一个用于用户,另一个用于管理员。当然他们共享同一个index.html文件。

在我的用户模块中,我希望<meta name="viewport" content="width=device-width, initial-scale=1">在<head></head>标签中有index.html

虽然我希望它在我的管理模块中被删除,并且只拥有手机的桌面视图。

我厌倦了在 admin first 组件构造函数中执行此操作:

import { Meta } from '@angular/platform-browser';
this.meta.removeTag('name="viewport"'); 
Run Code Online (Sandbox Code Playgroud)

标签正在被删除,但那是在应用程序开始呈现并存在此元标签之后,因为它在其中,index.html所以它不会给出所需的结果

有什么建议实际上有条件地添加这个元吗?困难的部分是它应该在 index.html 的头部。

viewport meta-tags typescript angular angular5

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

使用角度为 5 或 6 的 PouchDB

如何将 PouchDB 添加到 Angular 5 或 6 项目?我正在使用 Angular 6,但找不到任何方法来做到这一点。

pouchdb angular5 angular6

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

Angular 6 中 ngIf 中的多个条件

我想隐藏一个 div 并想显示另一个我在代码下面写的

我的代码

我的问题是我在 ngIf 中使用了多个条件但无法正常工作。单击“显示子内容 1”后,我想隐藏主要内容并希望显示所有按钮的“子内容 1”,反之亦然。我该怎么做。请帮忙。

typescript angular-ng-if angular angular5 angular6

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

打开两个模态时如何更改 ngx bootstrap 背景模态

在此处输入图片说明ngx-bootstrap for angular with bootstrap 4 version 当我们打开一个弹出窗口时,你会看到下面的代码,当我们从第一个弹出窗口打开另一个弹出窗口(模态)时,背景工作正常,背景不透明度没有反映在第一个弹出窗口上。当第二个模态打开时,不透明度不会改变如何改变第一个模态的不透明度(背景)。

import { Component, TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';

@Component({
  selector: 'demo-modal-service-nested',
  templateUrl: './service-nested.html'
})
export class DemoModalServiceNestedComponent {
  modalRef: BsModalRef;
  modalRef2: BsModalRef;
  constructor(private modalService: BsModalService) {}

  openModal(template: TemplateRef<any>) {
    this.modalRef = this.modalService.show(template, { class: 'modal-lg' });
  }
  openModal2(template: TemplateRef<any>) {
    this.modalRef2 = this.modalService.show(template, { class: 'second' });
  }
  closeFirstModal() {
    this.modalRef.hide();
    this.modalRef = null;
  }
}
Run Code Online (Sandbox Code Playgroud)
import { Component, TemplateRef } …
Run Code Online (Sandbox Code Playgroud)

bootstrap-modal ngx-bootstrap angular5

4
推荐指数
2
解决办法
3137
查看次数

在 angular 5 中进行生产构建时,“mat-expansion-panel”不是已知元素

我在 Angular 5 项目中使用延迟加载,并且在其中一个模块中导入了“mat-expansion-panel”。'mat-expansion-panel' 在开发模式下工作正常,但是当我为生产进行构建时,它显示错误,即 'mat-expansion-panel' 不是已知元素而没有显示任何行号。

我到处搜索,但没有找到任何东西。

production angular-material angular5

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

如何在有角度的材料中在 Snackbar 上添加 html 内容?

我为响应消息创建了烤面包机(小吃店)。我想在烤面包机(小吃店)上添加一个 html 内容,以便可以以正确的格式显示多条消息。

我试过了

var test ='<html> <body>' + '<h1>The Header</h1>'  +  '<p>The paragraph of text</p>' + '</body>  </html>';


this._toastr.error(test);
 _toastr : is my service.
 .error  : is my function in which I have to pass htmlContent 
Run Code Online (Sandbox Code Playgroud)

我的代码

var test = '<html> <body>' + '<h1>The Header</h1>'  +  '<p>The paragraph of text</p>' + '</body>  </html>';

this._toastr.error(test);
Run Code Online (Sandbox Code Playgroud)

输出应为:- 以下 xxx/xxx 的价格已于 2018 年 11 月 27 日输入。

  1. 你好,世界!
  2. 大家好!

我想要这个东西在烤面包机(小吃店)

需要像这样的输出应该在 html 表内容中

angular-material angular5

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

Angular 5 应用程序对于第一次使用的用户需要很长时间才能加载,我需要帮助来加快它的速度

Angular 5 应用程序在第一次在任何服务器上加载应用程序时需要更多时间,有关更多信息,我使用 AOT 编译器进行生产。

配置文件

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

performance angular5

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