简体   繁体   English

EventEmitter - 无法绑定,因为它不是已知属性 - Angular 8

[英]EventEmitter - Can't bind since it isn't a known property - Angular 8

I'm trying to use eventemitter but I am not being able to use it.我正在尝试使用 eventemitter,但我无法使用它。 I'm pretty new to angular and I don't understand what's going on!我对 angular 很陌生,我不明白发生了什么! for what I've seen in other posts I'm doing everything right!对于我在其他帖子中看到的内容,我做的一切都是正确的! I am trying to send an array through a component to another.我试图通过一个组件向另一个组件发送一个数组。 The interventionpage will be the one responsible and owner of this array, so whenever occurs a change in this array I want to export the data to the sync page.干预页面将是此数组的负责人和所有者,因此每当此数组发生更改时,我都想将数据导出到同步页面。 Can somebody tell me what am I doing wrong?有人能告诉我我做错了什么吗?

I am getting this error:我收到此错误:

*Uncaught Error: Template parse errors:
Parser Error: Bindings cannot contain assignments at column 9 in [message=$event] in ng:///SyncPageModule/SyncPage.html@40:37 ("

  <ion-card>
      <app-intervention [eventTest]="[ERROR ->]message=$event"></app-intervention>
    <ion-item-divider>
        Acciones Pendientes ({{message}})
"): ng:///SyncPageModule/SyncPage.html@40:37
Can't bind to 'eventTest' since it isn't a known property of 'app-intervention'.*

Here's my code:这是我的代码:

InterventionPage.ts InterventionPage.ts

import { EventEmitter } from 'events';

@Component({
  selector: 'app-intervention',
  templateUrl: './intervention.page.html',
  styleUrls: ['./intervention.page.scss'],
})
export class InterventionPage implements OnInit {

  constructor(private router: Router,
    public alertController: AlertController) { }

  service: any;
  initialDate: string;
  endDate: string;
  initialTime: string;
  endTime: string;
  startingTime: string;
  teste_array: any = [];
  interventions: any = ["test", "teste", "testee"];
  @Output() public eventTest = new EventEmitter();

  sendsData() {
    this.interventions.push("testThroughClick");
    this.eventTest.emit(this.interventions.length);

    console.log("interventions length: ")
    console.log(this.interventions.length);
  }

SyncPage.ts同步页面.ts

import { InterventionPage } from '../intervention/intervention.page';


@Component({
  selector: 'app-sync',
  templateUrl: './sync.page.html',
  styleUrls: ['./sync.page.scss'],
})
export class SyncPage implements OnInit {

  services: any = [];
  teste: string;
  teste_array: any = [];
  nr: any;
  public message = "";


  constructor(private interventionsPage: InterventionPage) {
     }

}

SyncPage.HTML同步页面.HTML

<ion-card>
      <app-intervention [eventTest]="message=$event"></app-intervention>
    <ion-item-divider>
        Acciones Pendientes ({{message}})
    </ion-item-divider>
</ion-card>

Change改变

import { EventEmitter } from 'events';

to

import { EventEmitter } from '@angular/core';

and,和,

<app-intervention (eventTest)="message=$event"></app-intervention>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 角度-无法绑定到“属性”,因为它不是“ a”的已知属性 - Angular - Can't bind to 'property' since it isn't a known property of 'a' Angular 6 无法绑定到“*ngIf”,因为它不是已知属性 - Angular 6 Can't bind to '*ngIf' since it isn't a known property Angular 2 RC 5 - 无法绑定到&#39;...&#39;,因为它不是&#39;...&#39;的已知属性 - Angular 2 RC 5 - Can't bind to '…' since it isn't a known property of '…' Angular无法绑定到“ dirUnless”,因为它不是已知属性 - Angular Can't bind to 'dirUnless' since it isn't a known property Angular 7 无法绑定到“routerlink”,因为它不是“a”的已知属性 - Angular 7 and can't bind to 'routerlink' since it isn't a known property of 'a' 无法绑定到“ngForOf”,因为它不是 angular 5 中的已知属性 - Can't bind to 'ngForOf' since it isn't a known property in angular 5 Angular 2无法绑定到'ngif',因为它不是已知属性 - Angular 2 Can't bind to 'ngif' since it isn't a known property 无法绑定,因为它不是角度分量的已知属性 - Can't bind since it isn't a known property of angular component 无法绑定到“”,因为它不是“ angular 2”的已知属性 - can't bind to '' since it isn't a known property of '' angular 2 无法绑定到属性,因为它不是元素的已知属性 - Can't bind to property since it isn't a known property of element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM