A
A
Alexander Sharomet2017-05-18 16:37:17
Angular
Alexander Sharomet, 2017-05-18 16:37:17

How to pass data from one component to another in Angular 2?

Hello.
How can I pass html code from one component to another.
The meaning is this.
I created a modal window and I want to use one modal window on the entire site, that is, when a button is pressed, a window with content is called, when another button is clicked, the same window is called but with different content.
modal.component.ts

import { Component } from '@angular/core';
@Component({
    moduleId: module.id,
    selector:'app-modal',
    template: `
<div class="modal-body">
                <modal-content></modal-content>//Сюда должен передаваться новый контент
</div>
`
})
export class ModalComponent {
    modalTitle:string = 'Modal';
}

modal.content.component.ts
import { Component } from '@angular/core';
@Component({
    selector: 'modal-content',
    template: , // То есть сюда я должен подставлять новый контент?
})
export class ModalContentComponent {
}

What is the best way to do this, or where to look? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Naim, 2017-05-19
@sharomet

https://www.npmjs.com/package/ng2-bootstrap-modal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question