<small id='WLPFV'></small><noframes id='WLPFV'>

  • <legend id='WLPFV'><style id='WLPFV'><dir id='WLPFV'><q id='WLPFV'></q></dir></style></legend>
  • <tfoot id='WLPFV'></tfoot>
    <i id='WLPFV'><tr id='WLPFV'><dt id='WLPFV'><q id='WLPFV'><span id='WLPFV'><b id='WLPFV'><form id='WLPFV'><ins id='WLPFV'></ins><ul id='WLPFV'></ul><sub id='WLPFV'></sub></form><legend id='WLPFV'></legend><bdo id='WLPFV'><pre id='WLPFV'><center id='WLPFV'></center></pre></bdo></b><th id='WLPFV'></th></span></q></dt></tr></i><div id='WLPFV'><tfoot id='WLPFV'></tfoot><dl id='WLPFV'><fieldset id='WLPFV'></fieldset></dl></div>

      <bdo id='WLPFV'></bdo><ul id='WLPFV'></ul>

        从一个组件调用函数到另一个组件Angularjs 2

        Call function from one component to another component Angularjs 2(从一个组件调用函数到另一个组件Angularjs 2)
        <i id='P1VTE'><tr id='P1VTE'><dt id='P1VTE'><q id='P1VTE'><span id='P1VTE'><b id='P1VTE'><form id='P1VTE'><ins id='P1VTE'></ins><ul id='P1VTE'></ul><sub id='P1VTE'></sub></form><legend id='P1VTE'></legend><bdo id='P1VTE'><pre id='P1VTE'><center id='P1VTE'></center></pre></bdo></b><th id='P1VTE'></th></span></q></dt></tr></i><div id='P1VTE'><tfoot id='P1VTE'></tfoot><dl id='P1VTE'><fieldset id='P1VTE'></fieldset></dl></div>

        <small id='P1VTE'></small><noframes id='P1VTE'>

          • <legend id='P1VTE'><style id='P1VTE'><dir id='P1VTE'><q id='P1VTE'></q></dir></style></legend>

                • <bdo id='P1VTE'></bdo><ul id='P1VTE'></ul>

                  <tfoot id='P1VTE'></tfoot>
                    <tbody id='P1VTE'></tbody>
                • 本文介绍了从一个组件调用函数到另一个组件Angularjs 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将值从一个组件传递到另一个组件.

                  I want to pass value from one component to another component.

                  也就是说,我需要将值从仪表板组件传递给标题组件

                  i.e., I need to pass value from Dashboard Component to Header Component

                  这是我的仪表板组件

                  import{Component}from '@angular/core';
                  import { Header } from '../../layout/header.component';
                  export class Dashboard{
                  showAlert(id : any)
                    {
                        setItem(id);
                    }
                  }
                  

                  这是我的 Header 组件

                  import { Component, OnInit } from '@angular/core';
                  @Component({
                    selector: 'header',
                    templateUrl: './header.component.html',
                  })
                  export class Header{   
                    public setItem(id : any)
                    {
                      console.log('Exported value'+id)
                    }
                  }
                  

                  但是总是给找不到setItem

                  我做错了什么,我该如何解决?

                  What is the mistake i am doing and how can i fix this ?

                  注意:我在 Angularjs 2 中这样做

                  Note : I am doing this in Angularjs 2

                  推荐答案

                  如果元素引发事件,您可以通过事件绑定来监听它们.参考角度文档 https://angular.io/guide/template-syntax#event-绑定以获得深入的知识.

                  If the element raises events, you can listen to them with an event binding. Refer to the angular doc https://angular.io/guide/template-syntax#event-binding for in depth knowledge.

                  仪表板组件

                  import{Component}from '@angular/core';
                  import { Header } from '../../layout/header.component';
                  @Component({
                    selector: 'dashboard',
                    templateUrl: './dashboard.component.html',
                  })
                  export class Dashboard{
                    @Output() setItemEvent  = new EventEmitter();
                  
                  showAlert(id : any)
                    {
                        this.setItemEvent.emit(id);
                    }
                  }
                  

                  标题组件

                  import { Component, OnInit } from '@angular/core';
                  @Component({
                    selector: 'header',
                    template: '<dashboard (setItemEvent)="setItem(param)"></dashboard>',
                  })
                  export class Header{   
                    public setItem(id : any)
                    {
                      console.log('Exported value'+id)
                    }
                  }
                  

                  这篇关于从一个组件调用函数到另一个组件Angularjs 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  <legend id='KehNS'><style id='KehNS'><dir id='KehNS'><q id='KehNS'></q></dir></style></legend>
                • <tfoot id='KehNS'></tfoot>

                      <tbody id='KehNS'></tbody>

                    <small id='KehNS'></small><noframes id='KehNS'>

                      <bdo id='KehNS'></bdo><ul id='KehNS'></ul>

                          1. <i id='KehNS'><tr id='KehNS'><dt id='KehNS'><q id='KehNS'><span id='KehNS'><b id='KehNS'><form id='KehNS'><ins id='KehNS'></ins><ul id='KehNS'></ul><sub id='KehNS'></sub></form><legend id='KehNS'></legend><bdo id='KehNS'><pre id='KehNS'><center id='KehNS'></center></pre></bdo></b><th id='KehNS'></th></span></q></dt></tr></i><div id='KehNS'><tfoot id='KehNS'></tfoot><dl id='KehNS'><fieldset id='KehNS'></fieldset></dl></div>