@Leopandro
Разработчик CRM/ERP систем

Как вызвать функцию компонента с другого?

Здравствуйте, у меня появилась одна проблема - не знаю как вызвать функцию компонента, так же как я вызываю функцию $('#modal_ask').modal();

Вот компонент:
import {Component, OnInit, Input, OnChanges, SimpleChanges} from '@angular/core';

declare var $: any;

@Component({
    selector: 'app-terminal-modal',
    templateUrl: './terminal-modal.component.html',
    styleUrls: ['./terminal-modal.component.css']
})
export class TerminalModalComponent implements OnChanges, OnInit {
    @Input() model: any;
    @Input() wtf: any;
    id: any = '#profile';

    constructor() {
    }

    ngOnInit() {
        console.log(this.model);
    }

    modalReviewsText() {
        $('#modal_ask').modal();
    }

    ngOnChanges(changes: SimpleChanges) {
        console.log(this.model);
        if (this.model)
            this.showModal();
    }

    showModal() {
        console.log(this.id);
        $(this.id).modal();
    }

    hideModal() {
        console.log(this.id);
        $(this.id).modal('hide');
    }
}


Это в родительском контроллере:
<app-terminal-modal
                            [wtf]="time"
                            [model]="parking"
                    ></app-terminal-modal>


Приходится открывать модалку через изменение значения инпута, как я могу вызвать функцию
showModal() {
        console.log(this.id);
        $(this.id).modal();
    }
напрямую, как функцию?
  • Вопрос задан
  • 472 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы