score:0

or how to use the 'app-tooltip' selector in another component directly?

you just add the component's selector to the other component, as you normally would. <app-tooltip></app-tooltip>. don't forget to add it in declarations of app.module.ts (or at a level where the other component still can make use of it).

example

component1.component.ts

import { component, oninit } from '@angular/core';

@component({
    selector: 'app-component1',
    templateurl: 'component1.component.html'
})

export class component1component implements oninit {
    constructor() { }

    ngoninit() { }
}

component1.component.html

<h1>this is component 1</h1>
<app-component2></app-component2>

component2.component.ts

import { component, oninit } from '@angular/core';

@component({
    selector: 'app-component2',
    templateurl: 'component2.component.html'
})

export class component2component implements oninit {
    constructor() { }

    ngoninit() { }
}

component2.component.html

<h3>this is component 2</h3>

app.module.ts

...
import { appcomponent } from './app.component';
import { component1component, component2component } from './components/index';

@ngmodule({
  declarations: [
    ...
    appcomponent,
    component1component, component2component
  ],
  imports: [
    ...
  ],
  providers: [],
  bootstrap: [appcomponent]
})
export class appmodule { }

app.component.html

<app-component1></app-component1>

result

component in component


Related Query

More Query from same tag