将方法从一个组件导出到另一组件

时间:2018-12-29 11:28:12

标签: angular typescript

我在一个组件中定义了一种方法。我想在另一个组件中使用该方法。基本上是ExportImport,但我不知道该如何使用方法。

abc.component.ts

import { Component, OnInit } from '@angular/core';
export class ABCComponent {

    getUser(){
        //Some code
    }
}

def.component.ts

import { Component, OnInit } from '@angular/core';
import { ABCComponent } from '../../abc.component.ts';
export class DEFComponent implements OnInit {
    ngOnit(){
        //I want to use getUser method here from abc.component.ts
    }
}

0 个答案:

没有答案
相关问题