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
Source: stackoverflow.com
Related Query
- How to append angular2 component to d3 selection?
- How do I append DOM to an Angular 2 component and still get encapsulated styles
- How to catch onDestroy in Angular2 for component that is removed
- Angular2 component not called when I do d3JS append
- How to access the parentNode of a selection to raise an element?
- D3js how to append 2 children at the same level in .enter context
- How can I use d3 classed selection to have name as function
- How to register multiple external listeners to the same selection in d3?
- D3 How to change dataset based on drop down box selection
- D3: Append duplicates of a selection
- Can I run a component method only in the client using Angular2 Universal?
- How to append text to a div in D3
- How to create a reusable component in D3 with an API that manipulates each instance of the component?
- How to append text to a line in d3.js
- How to disable brush selection on right click in d3.js
- How to append a text element with inline tspan children?
- How to get the parent selection in d3?
- How can I copy the content of my SVG and append it to another SVG frame?
- How to append the arrow marker dynamically in force layout d3.js
- D3.js How to append local image
- How to append text in d3 force layout?
- How to remove circular dependencies in d3 selection using rollupjs?
- How to append multiple rectangles in D3?
- how to append option into select combo box in d3
- How to get value from the element using selection in d3
- d3.js / svg - how to dynamically append text to my arcs
- How can I get access to the current selection inside a D3 callback?
- D3 How to append needle at a certain point on a curve
- D3.js how to embed selection into a new element
- How to create selection from DOM element itself
More Query from same tag
- I can't get d3 transition to work with requestAnimationFrame
- D3 Transition Path Left And Shift Up/Down Simultaneously
- D3 Bounded Panning
- trouble adding label when appending checkbox's with d3
- How to use d3.js and node?
- Binding dc.js to Google Maps with crossfilter
- Show a D3 SVG Within a Tooltip
- Making a search box using javascript and incorporate a CSV
- Looping a Json object in map.arc()
- How to create shaded path in d3 and SVG?
- Displaying .json map in D3 Javascript
- D3 - reordering elements based on their data
- migrating to d3 v4 cause duplicates on drag
- xExtend Values not updating
- How can I change the body of template in meteor with a html on another template?
- Best way to use selection.filter to get multiple selections
- adding text in d3.js multi level pie chart
- How can I simulate a click on d3 tree nodes?
- How do I implement d3's enter update exit pattern for an area chart with focus and context?
- Why are there gaps between rects in a D3 linechart?
- How to put a legend in a pie chart in d3.js
- Show labels based on collision detection scatter plot in d3js
- Legend in horizontal multi bar chart
- How to stop force-directed graph simulation
- Can I reduce D3 geoPath canvas plot point artifacts in Chrome and Firefox on macOS?
- Using D3 Liquid Fill Gauge with React causes re-render issues
- Is there a way to reduce lagging of a guideline that follows the mouse pointer?
- How to keep the order of slices fixed in a pie chart? [d3]
- NVD3 width error inside Tabs
- Stacked area graph not rendering