Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript @输出()事件发射器不工作_Javascript_Angular_Typescript_Ionic2_Eventemitter - Fatal编程技术网

Javascript @输出()事件发射器不工作

Javascript @输出()事件发射器不工作,javascript,angular,typescript,ionic2,eventemitter,Javascript,Angular,Typescript,Ionic2,Eventemitter,我尝试制作一个查看更多按钮,以便在单击时获得更多搜索结果 我的标题在单独的arrchivos中,我与以下内容一起使用: <ion-header>   <page-header> </page-header> </ion-header> 而search modal.ts控制器如下所示: <div (click)="seeMoreResults($event)"> <button color="primary" bloc

我尝试制作一个
查看更多
按钮,以便在单击时获得更多搜索结果

我的标题在单独的arrchivos中,我与以下内容一起使用:

<ion-header>
  <page-header> </page-header>
</ion-header>
search modal.ts
控制器如下所示:

  <div (click)="seeMoreResults($event)">
    <button color="primary" block>see more</button>
  </div>
Import {Component, EventEmitter, Output} from '@ angular / core';

@Component({
  selector: 'page-search-modal',
  templateUrl: 'search-modal.html',
})
export class SearchModalPage {

@Output()
public updateSearchResults = new EventEmitter();

seeMoreResults(event) {
    this.countSearchResult = Object.keys( this.searchResult ).length; // "this.searchResult" are the search results that arrive when something is typed.
    this.updateSearchResults.emit( this.countSearchResult );
}
header.html
包含以下内容:

<ion-toolbar (updateSearchResults)='updateSearchResults($event)'>
// Here is my search bar.
</ion-toolbar>
第一次搜索工作正常,这就是我省略代码的原因。 但是当我单击“查看更多”按钮时,它不会发出任何信息,我试图放置一个
console.log(“Run”)位于
header.ts的
updateSearchResults
内部,但从不打印

知道为什么吗

很抱歉翻译,我会说西班牙语。
(更新搜索结果)
输出需要绑定到它输出的组件上,即
页面搜索模式
(根据您的代码)。i、 e


//这是我的搜索栏。

复制粘贴时您的代码是否发生了问题?似乎有很多额外的空格,其中一些是语法错误。发射组件是接收组件的直接子组件吗?角度事件只上升了一个级别?代码已经被我使用google进行的翻译修改。我很抱歉。但我检查了代码中的语法,一切正常。我将直接从我的代码复制到这里。完成后我会发表评论。好的,我已经复制了代码。但是在我的标题调用中,我已经有了一个
如果我这样做,什么都不会发生:
PD:我试过了,但它对我无效。@Faber\u Hozz它不应该出现在你的
页面标题上,它应该在您的
页面搜索模式上
——您将其定义为输出。您目前的代码不起作用-如果这不是您实际拥有的代码,那么我们无法真正帮助您:\
updateSearchResults(lastTotal){
  this.search((10+lastTotal), lastTotal, true);
  // "search" is the method that makes me search and issues the result.
}
<page-search-modal (updateSearchResults)='updateSearchResults($event)'>
// Here is my search bar.
</page-search-modal