小编imn*_*ghn的帖子

角度误差:预期0个类型参数,但得到1

我得到类型错误,"预期0类型参数,但得到1"尽管遵循本教程到T. https://youtu.be/I317BhehZKM?t=57s

我已经指定:

  newUserInfoComplete:boolean = false
Run Code Online (Sandbox Code Playgroud)

但是我<boolean>在这一行中得到了上面指定的错误:

  @Output() newUserInfoCompleteEvent = new EventEmitter <boolean> ();
Run Code Online (Sandbox Code Playgroud)

此外,如果我只是省略<boolean>我得到此错误:

Argument of type 'boolean' is not assignable to parameter of type 'string'.
Run Code Online (Sandbox Code Playgroud)

和this.NewUserInfoComplete在这里加下划线:

this.newUserInfoCompleteEvent.emit(this.newUserInfoComplete);
Run Code Online (Sandbox Code Playgroud)

如果您要进行downvote,请留下关于如何改进我的问题的说明.谢谢.

这是我的组件:

import { Component, OnInit, Output } from '@angular/core';
import { slideToRight } from '../../../../router.animations';
import { Router, ActivatedRoute, UrlSegment } from '@angular/router';
import { EventEmitter } from 'protractor';

@Component({
  selector: 'app-new-user-input',
  templateUrl: './new-user-input.component.html',
  styleUrls: ['./new-user-input.component.css'],
  animations: [slideToRight()]
})
export class NewUserInputComponent implements OnInit {

  newUserInfoComplete:boolean …
Run Code Online (Sandbox Code Playgroud)

parent-child typescript angular

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

Angular / Mobile友好的方法是如何使用在组件类中找到的变量来修改伪元素上的属性的值?

有没有比我目前正在使用的组件变量更好的方法来修改伪元素属性? 我不是以Angular的方式这样做,但这是我的目标。 移植到移动设备时,我的方法肯定会中断。我想在组件样式表中放置一个变量:

零件:

@Input() public variable = variable;
Run Code Online (Sandbox Code Playgroud)

组件样式表:

input[type=range].MPslide.pvd-slider::-webkit-slider-runnable-track{
 background:linear-gradient(#568200, #568200) 0/variable 100% no-repeat #ccc
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,它在我的模板中不存在,因此无法在其上放置[ngClass]或[style.margin-left.px] =“ containerX-9”。目前,我正在通过设置全局CSS变量onFormChanges()来执行此操作。

零件:

  onFormChanges(): void {
this.myForm.valueChanges.subscribe(() => {
            document.documentElement.style.setProperty('--variable', variable)
}
}
Run Code Online (Sandbox Code Playgroud)

组件样式表:

background:linear-gradient(#568200, #568200) 0/var(--variable) 100% no-repeat #ccc
Run Code Online (Sandbox Code Playgroud)

但这似乎是一种解决方法,很难跟踪。 Angular的方法是什么?Angular是否无法在伪元素中使用组件变量值?我想念什么?有没有更清洁的方法可以做到这一点?感谢您的任何见解或建议!

javascript css angular

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

vs代码中的ftp-imple扩展名未显示远程文件内容

我没有使用git,因为我处于托管CMS的约束下,无法通过SSH进入其服务器。

我正在尝试使ftp简单在vs代码中工作,以便我可以编辑一个远程文件并将其保存,并可以在浏览器中查看更改。目前,它可以看到远程服务器上的文件,但是单击文件后看不到内容。

在我的配置文件中,我仅输入了sftp的授权,而为了真正看到内容,我还需要做其他事情吗?

这就是我尝试打开文件时的样子。如您所见,左侧的文件树是完全可见的。 在此处输入图片说明

也许以前有人遇到过这个问题...

html css ide visual-studio-code

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

错误类别“ FirebaseApp”错误地实现了接口“ App”

尝试提供我的angularCLI和Firebase导致此错误...我该怎么办?

node_modules / angularfire2 / app / firebase.app.module.d.ts(5,22)中的错误:错误TS2420:“ FirebaseApp”类错误地实现了“ App”接口。类型“ FirebaseApp”中缺少属性“ firestore”。node_modules / angularfire2 / app / firebase.app.module.d.ts(12,28):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / database / firebase_list_observable.d.ts(14,62):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / database / firebase_list_observable.d.ts(15,48):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / database / firebase_list_observable.d.ts(16,92):错误TS2694:命名空间'firebase' 没有导出成员“ Promise”。node_modules / angularfire2 / database / firebase_object_observable.d.ts(11,31):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / database / firebase_object_observable.d.ts(12,37):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / database / firebase_object_observable.d.ts(13,24):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / interfaces.d.ts(12,32):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules / angularfire2 / interfaces.d.ts(13,35):错误TS2694:命名空间“ firebase”没有导出的成员“ Promise”。node_modules …

npm firebase angular

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

漂亮的不按指定缩进

漂亮的人继续错误地格式化我的代码。我希望选项卡有4个空格(第二张图片),但是它忽略了编辑器设置,而是2个(第一张图片)。

我知道这是更漂亮的原因,因为当我禁用它时,代码会为我正确缩进。不幸的是,漂亮的其他功能丢失了。我已经尝试过卸载并重新安装。

那么,我缺少哪些设置更改?我肯定错过了什么。任何建议都是宏大的。谢谢。

这是我更改过的所有漂亮设置。

"prettier.singleQuote": true,
"prettier.eslintIntegration": true,
"prettier.tabWidth": 4,
"prettier.useTabs": true
Run Code Online (Sandbox Code Playgroud)

不正确的

正确

typescript visual-studio-code prettier

5
推荐指数
3
解决办法
3141
查看次数

无法读取 Angular 中未定义的属性“导航”

所有关于 Angular 错误的帮助文章都说要确保已注入“路由器”,如下所示:

构造函数(路由器:路由器......

我已经做到了。

我不确定还能做什么。在开始对路由进行故障排除之前,我必须解决这个问题。

我的目标:允许用户导航到子路线。允许用户单击时关闭当前路线。

因此当前地址为: https://localhost:4200/layout/usermanagement/(newuser:newuser/(newuserinput:newuserinput))

单击后,我将被路由到: https://localhost:4200/layout/usermanagement/(newuser:newuser/(newuserorginfo:newuserorginfo))

另外,单击另一个按钮后,我将被路由到: https://localhost:4200/layout/usermanagement/(newuser:newuser))

这是我的组件、模块和模板。

组件 new-user-input.component.ts

import { Component, OnInit } from '@angular/core';
import { slideToRight } from '../../../../router.animations';
import { Router, ActivatedRoute, UrlSegment } from '@angular/router';

@Component({
  selector: 'app-new-user-input',
  templateUrl: './new-user-input.component.html',
  styleUrls: ['./new-user-input.component.css'],
  animations: [slideToRight()]
})
export class NewUserInputComponent implements OnInit {
  router: Router;

  constructor(router: Router, r: ActivatedRoute) {
    r.url.subscribe((s: UrlSegment[]) => {
      console.log("url", s); //https://vsavkin.com/angular-router-understanding-router-state-7b5b95a12eab
    });
  }

  ngOnInit() {
  }

  displaySibling() {
    console.log(this.router);
    this.router.navigate(['../', { outlets: { newuserorginfo: …
Run Code Online (Sandbox Code Playgroud)

single-page-application angular-routing angular-ui-router angular

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

ng-template 上不能有事件吗?嵌入模板上的任何指令都不会发出事件绑定点击

我试图简单地使用 *ngIf ;else 来渲染或不渲染按钮,但不断收到此错误。看来我不能在我的 ng-template 上举办活动?不可能这样。我肯定做了一些明显错误的事情。

事件名称(单击)显然拼写正确,据我所知,我需要的所有指令浏览器和通用模块均已导入并列在 NgModule 元数据中。

错误:

嵌入模板上的任何指令都不会发出事件绑定单击。确保事件名称拼写正确,并且所有指令都列在“@NgModule.declarations”中。

这是我针对此问题找到的唯一真正的解决方案: 解决方案 1,但我将 BrowserModule 和 CommonModule 都导入到 AppModule 中,并且将最接近发生错误的模块导入。

嵌入模板上的任何指令都不会发出事件绑定单击。 确保事件名称拼写正确,并且所有指令都列在“@NgModule.declarations”中。

非常接近只使用两个 *ngIf(仅供参考)...为什么我不能在我的 ng-template 上有一个事件?我已经用属性替换了changeViewState(),并将(单击)事件更改为(激活)和(鼠标悬停)事件...它似乎不像ng-template上的任何(事件)...

我已将问题代码复制粘贴到我的应用程序周围,但每次都会出错。

‘问题代码’:

<div *ngIf="(this.stateUserReqValid === 'userInfo' || this.stateUserReqValid === 'orgInfo' || this.stateUserReqValid === 'supInfo' || this.stateUserReqValid === 'secInfo'); else ele"
  class="userManHover" (click)="changeViewState('userInfo');" [ngClass]="{'userManSelect': stateUserReq =='userInfo'}">
  <h4 class="font-weight-light">
    <span class="blade-2-number" [ngClass]="{'blade-2-activated-number' :  stateUserReq =='userInfo'}">1 </span> User Information &nbsp;
    <span class="icon-accept user-man-accept"></span>
  </h4>
</div>
<ng-template #ele class="userManHover" (click)="changeViewState('userInfo')" [ngClass]="{'userManSelect': stateUserReq =='userInfo'}">
  <h4 class="font-weight-light">
    <span class="blade-2-number" [ngClass]="{'blade-2-activated-number' : …
Run Code Online (Sandbox Code Playgroud)

angular-ng-if angular

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

我的模板引用变量 .nativeElement 未定义

this.child02.nativeElement 未定义,我不知道为什么。我究竟做错了什么?谢谢你。这是我目前的堆栈闪电战。

app.component.ts:

import { Component,ElementRef,ViewChild } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {

switchDirection = true;
head: ElementRef;

@ViewChild('child02') child02: ElementRef;

  onScroll(event: Event) {
    console.log("viewBoundaryL:" + (event.target as HTMLElement).scrollLeft);
    if((event.target as HTMLElement).scrollLeft >= 50 && this.switchDirection === true){
  console.log("nativeElement:" + this.child02.nativeElement)
  console.log(this.child02)
  console.log('snap')
this.child02.nativeElement.scrollIntoView({ behavior: 'smooth' });
  this.switchDirection = false;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

app.component.html:

Keep an eye on the console while scrolling...
<div class="container"  (scroll)="onScroll($event)" >

<child1></child1>
<child2 #child02></child2> …
Run Code Online (Sandbox Code Playgroud)

typescript angular-template angular

5
推荐指数
2
解决办法
3825
查看次数

组件声明,模板变量声明和元素引用不包含此类成员

这可能是一个简单的修复。该元素应该在悬停时从页面顶部滑出。我的代码按预期工作,但出现此错误。

错误:

[Angular] Identifier 'compartmentOpen' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
Run Code Online (Sandbox Code Playgroud)

我尝试使用ngIf在元素的模板中定义它,如下所示:#compartmentOpen它可以使错误消失,但是由于试图获取整个元素的真实性,因此代码无法运行。

我也尝试过这样定义它:在组件中,但不会执行任何操作。

模板:

<div class="container">
  <div #compartmentOpen
    (mouseover)="compartmentOpen = true"
    (mouseout)="compartmentOpen = false"
    class="inner-container">



    <div class="grid-center">

      <div class="z-bottom"
        *ngIf="compartmentOpen"> Facebook Login coming soon!
        <br>
        <br>
        <br>
        <br>
      </div>


      <button (click)="googleLogin()"
        class="btn btn-primary google-btn-size animated bounce">
        Login with Google
      </button>
      <br>

      <div id="wave">
        <span class="dot dot-ani"></span>
        <span class="dot dot-ani"></span>
        <span class="dot dot-ani"></span>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

零件:

import …
Run Code Online (Sandbox Code Playgroud)

variables typescript angular

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

单选按钮值在类型元素上不存在

嗨,我只是想从我正在处理的 Angular 项目中的组件上的几个单选按钮中获取值。如果我放了相同的违规代码..

this.format = document.querySelector('input[name="case"]:checked').value;
Run Code Online (Sandbox Code Playgroud)

...在控制台日志中的 if 语句中,它不会引发错误。此外,当我重新加载 vs 代码时,有时也不会抛出错误并且它运行良好。

那么有人能明白为什么我会收到这个错误吗?谢谢你的帮助。如果您需要更多信息,请告诉我。

'file:////src/app/input-format2.directive.ts'
severity: 'Error'
message: 'Property 'value' does not exist on type 'Element'.'
at: '15,72'
source: 'ts'
code: '2339'
Run Code Online (Sandbox Code Playgroud)

这是指令:

import { Directive, ElementRef, HostListener, Input } from '@angular/core';

@Directive({
  selector: '[appInputFormat2]'
})
export class InputFormat2Directive {
  // tslint:disable-next-line:no-input-rename
  @Input('appInputFormat2') format;

  constructor(private el: ElementRef) {}

  @HostListener('blur')
  onBlur() {
    const value: string = this.el.nativeElement.value;
    this.format = document.querySelector('input[name="case"]:checked').value;
    if (this.format === 'lowercase') {
      this.el.nativeElement.value = value.toLowerCase();
    } else {
      this.el.nativeElement.value = …
Run Code Online (Sandbox Code Playgroud)

typescript visual-studio-code angular

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