标签: angular6

Angular 6 - run方法每10秒服务一次

我有这个服务使用HttpClient来获取一些数据:

checkData() {
    return this.http.get('my url');
}
Run Code Online (Sandbox Code Playgroud)

我在脚注组件上调用它并显示结果:

ngOnInit() {
    this.myservice.checkdata().subscribe( result => { this.statustext = result } );
}
Run Code Online (Sandbox Code Playgroud)

这有效,但我需要每10秒运行一次这样的方法,因此它是最新的.

我怎样才能做到这一点?

rxjs typescript angular angular6

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

Angular 6在angular.json中加载css文件夹

我想将我的html模板转换为角度应用程序.我有一个名为plugins和img文件夹的css文件夹.

当我添加时:

 "styles": [
          "src/assets/plugins/listtyicons/style.css",
          "src/assets/plugins/jquery-ui/jquery-ui.min.css",
          "src/assets/plugins/bootstrap/css/bootstrap.min.css",
          "src/assets/plugins/plugins/isotope/isotope.min.css",
          "src/styles.css"

        ]
Run Code Online (Sandbox Code Playgroud)

angular.json文件中的此代码我在尝试启动角度应用程序时遇到错误.我把我的插件文件夹放在assets文件夹中.我收到此错误:

 ERROR in multi ./src/assets/plugins/listtyicons/style.css 
./src/assets/plugins/jquery-ui/jquery-ui.min.css ./src/assets/plugins/bootstrap/css/bootstrap.min.css ./src/assets/plugins/plugins/isotope/isotope.min.css ./src/styles.css
Module not found: Error: Can't resolve 
'/Users/nilay/angular/bes/src/assets/plugins/plugins/isotope/isotope.min.css' 
in '/Users/nilay/angular/bes'
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会收到这个错误.

css angular6

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

Firefox上的Angular 6 [WDS]断开连接错误

我使用Angular,我只在Firefox" [WDS] Disconnected! " 上获得控制台错误.

Firefox控制台错误消息在这里

这是我的Angular-Cli版本.

Angular CLI: 6.0.1
Node: 8.11.1
OS: win32 x64
Angular: 6.0.1
... cli, common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.1
@angular-devkit/build-angular     0.6.1
@angular-devkit/build-optimizer   0.6.1
@angular-devkit/core              0.6.1
@angular-devkit/schematics        0.6.1
@angular/animations               6.0.4
@ngtools/webpack                  6.0.1
@schematics/angular               0.6.1
@schematics/update                0.6.1
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.6.0
Run Code Online (Sandbox Code Playgroud)

firefox webpack-dev-server angular angular6

9
推荐指数
2
解决办法
8991
查看次数

找不到模块:错误:无法解析selenium-webdriver中的"http"

我发现了这个错误:

./node_modules/selenium-webdriver/http/index.js中的错误找不到模块:错误:无法解析'/ Users/mac/angular/restaurantApp/node_modules/selenium-webdriver/http'中的'https'

任何人都可以帮我解决这个问题.

谢谢

angular6

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

如何将数据从角度材质对话框传递到父组件?

我正在使用角度6,并且有一个打开对话框的按钮。在对话框中,我有一个获取用户数据的表单,然后有两个按钮可以提交和取消。我试图在控制台中显示表单的数据,但是它返回未定义的!有什么问题?这是代码的一部分:

main.component.ts:

import { Work } from '../../../../classes/work_shift';
import { DialogContentComponent} from './dialog-content/dialog-content.component';
export class WorkShiftsComponent implements OnInit {
 shifts: Work[];
  name: string;
  start: string;
  end: string;
  constructor(public dialog: MatDialog, private shiftService: WorkShiftsService) { }

  ngOnInit() {
  }

  openDialog() {
    const dialogRef = this.dialog.open(DialogContentComponent, {
      width: '640px',
      disableClose: true,
      data: {name: this.name, start: this.start, end: this.end}
    });
    dialogRef.afterClosed().subscribe(result => {
      console.log('The dialog was closed');
      console.log(result);//returns undefined
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

dialogContent.component.html:

    <mat-dialog-content>
  <form class="example-form">
    <div fxLayout="column" fxLayoutAlign="space-around" class="form">
      <div class="input">
        <mat-form-field …
Run Code Online (Sandbox Code Playgroud)

typescript angular-material angular angular6

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

在Angular 6中如何使大小写不敏感的网址格式?

就我而言,我想以不区分大小写的方式支持相同的网址。

示例:它应该支持所有网址

localhost:1029/documentation
localhost:1029/DOCUMENTATION
localhost:1029/DOCUMENTAtion
localhost:1029/docuMENTATION
Run Code Online (Sandbox Code Playgroud)

angular angular5 angular6

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

Canvas-橡皮擦在画布保存为图像后在画布上绘制黑色线条

在画布上绘图工作得很好.即使橡皮擦也工作得很好.问题是,当画布保存为图像时,它绘制的是黑色线而不是橡皮擦.

为了更好地理解,我添加了屏幕截图和代码.

1.在删除抽奖时 -

一个.源代码 -

erase(){
      this.ctx.globalCompositeOperation = 'destination-out';
    } 

handleMove(ev){

  // let ctx = this.canvasElement.getContext('2d');
  let currentX = ev.touches[0].pageX - this.offsetX;
  let currentY = ev.touches[0].pageY - this.offsetY;

  this.ctx.beginPath();
  this.ctx.lineJoin = "round";
  this.ctx.moveTo(this.lastX, this.lastY);
  this.ctx.lineTo(currentX, currentY);
  this.ctx.closePath();
  this.ctx.strokeStyle = this.currentColour;
  this.ctx.lineWidth = this.brushSize;
  this.ctx.stroke();      


  this.undoList.push({
    x_start: currentX,
    y_start: currentY,
    x_end: this.lastX,
    y_end: this.lastY,
    color: this.currentColour,
    size: this.brushSize,
    mode: this.ctx.globalCompositeOperation
  });

  this.lastX = currentX;
  this.lastY = currentY;

}
Run Code Online (Sandbox Code Playgroud)

湾 输出 -

在此输入图像描述

2.画布保存为图像 -

一个.代码 -

this.ctx.clearRect(0, 0, this.canvasElement.width, this.canvasElement.height);
    setTimeout(() …
Run Code Online (Sandbox Code Playgroud)

javascript canvas css3 html5-canvas angular6

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

代理配置在角度6中不起作用

我有metronic_v5.5.2 Angular版本,我正在尝试将其angular版本与我的后端API集成在一起。

因为我对这一切还很陌生,所以现在问题出在我的代理配置上,该配置无法按照我的期望工作。

以下是proxyconfig.json文件的代码

{
    "/api": {
        "target": "https://localhost:5001",
        "secure": false,
        "changeOrigin": true,
        "logLevel": "debug"
    }
}
Run Code Online (Sandbox Code Playgroud)

图像显示请求正在路由到URL“ https:// localhost:5001 / api / auth / login” POST / api / auth / login-> https:// localhost:5001

但是,在浏览器的控制台中,此请求实际上是路由到URL ,它返回401错误,网址为http:// localhost:4200 / api / auth / login。我无法通过单击按钮将其路由到URL:https:// localhost:5001 / api / auth / login

以下是HTML代码

<!--begin::Form-->
<form class="m-login__form m-form" name="form" (ngSubmit)="f.form.valid && submit()" #f="ngForm" novalidate>
    <div class="form-group">
        <mat-form-field>
            <mat-label>Email</mat-label>
            <input matInput type="email" name="email" placeholder="Email address" autocomplete="off" [(ngModel)]="model.email" #email="ngModel" email="true" required> …
Run Code Online (Sandbox Code Playgroud)

angular-ui-router asp.net-core-webapi angular angular6

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

如何在角度中的另一个函数终止后调用函数

我有3个功能,我想一个接一个地打电话

openTryFunction(){
    // function one
    this.functionOne();
    // after function one
    this.functionTwo();
    // after function two
    this.functionTree(); }
Run Code Online (Sandbox Code Playgroud)

typescript angular angular6

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

设置了selectedIndex的角度步进器matStepperNext / matStepperPrevious不起作用

我使用的是matStepper,当我将selectedIndex设置为3时,无法使用下一个和上一个导航。我可以单击水平步进器中的(1),然后照常使用下一个/上一个。所有表格均有效,单击(1)后,我可以使用1-7的下一个导航。

注意我有this.selectedIndex = 3; 硬编码

<mat-horizontal-stepper #stepper
                        [linear]="true"
                        [selectedIndex]="this.selectedIndex"
                        (selectionChange)="selectionChange(stepper)">

  <mat-step [stepControl]="form1">
    <app-observer-information></app-observer-information>
  </mat-step>
...
  <mat-step [stepControl]="form7">
    <app-observer-agreement></app-observer-agreement>
  </mat-step>

</mat-horizontal-stepper>



export class ObservationStatementStepperComponent implements OnInit {

  @ViewChild('ObserverInformationComponent') public component1: ObserverInformationComponent;
  ..
  @ViewChild('ObserverAgreementComponent') public component7: ObserverAgreementComponent;

  public selectedIndex: number;

  constructor(private sorDataService: SorDataService) {

    this.selectedIndex = 3; // Number(sorDataService.selectedIndex);
  }

  public ngOnInit() {
  }

  public selectionChange(stepper) {

    this.sorDataService.synchronizeStepper(stepper.selectedIndex + 1);
  }

  /**
   * @see /sf/ask/3394927651/
   */
  get form1() {
    return this.component1 ? this.component1.form : null;
  }
  ...
  get form7() {
    return this.component7 …
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular-material-stepper angular6

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