Angular 7 / ngx-bootstrap 4.0.1
Dependencies :
"bootstrap": "3.3.7",
"bootstrap-colorpicker": "2.5.1",
"bootstrap-duallistbox": "3.0.6",
"bootstrap-markdown": "2.10.0",
"bootstrap-progressbar": "0.9.0",
"bootstrap-slider": "9.8.0",
"bootstrap-tagsinput": "0.7.1",
"bootstrap-timepicker": "0.5.2",
In Angular 7, I've a component. It's juste a button and when you click on it, it's show a modal.
If I call it from an element like a div, it's working.
But when I call it from a dropdown, the modal won't appear.
Here is my code :
Normal call : modal is visible :
<shared-article-copy (ArticleEM)="addArticle($event, 'articleCopie')" [agentId]="this.samplesBill.recipient.agent_Id"
*ngIf="this.samplesBill && this.samplesBill.recipient"></shared-article-copy>
Call from a dropdown menu : modal is not visible :
<div class="btn-group">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Test 1</button>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Test2 <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li> <shared-article-copy (ArticleEM)="addArticle($event, 'articleCopie')" [agentId]="this.samplesBill.recipient.agent_Id"
*ngIf="this.samplesBill && this.samplesBill.recipient"></shared-article-copy></li>
</ul>
</div>
</div>
I think, the view of my component is bind to the li element and not to the body.
here is a part of the code of my component view shared-article-copy :
<button type="button" class="btn btn-labeled btn-primary" (click)="loadModalArticleImport()" ng-dblclick="return false;">
<span class="btn-label">
<i class="fa fa-plus"></i>
</span>
</button>
<div bsModal #calculatorModal="bs-modal" class="modal fade" tabindex="0" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true" style="background-color: white" [hidden]="!articleCalculator" (onHidden)="closeCalculatorModal()"
>
<div class="modal-dialog modal-lg" style="background-color: white">
<div class="modal-content">
<div class="modal-header" *ngIf="articleCalculator">
Modal Header
</div>
<div class="modal-body">
modal body !
</div>
</div>
</div>
</div>
I can't copy all the code of the component because it's not relevant.
here is a part to :
export class SharedArticleCopyComponent implements OnInit {
@Input() buttonClass: string;
@Input() agent: Agent; // pour avoir un client par défaut
@Input() agentId: string; // Quand on a pas lagent mais que son ID people
@Input() textTitle: string = 'Copier un article existant';
@Input() calculatorTitle: string = 'Détails de l\'article: ';
@Input() AgentReadonly: boolean = false;
@Output() public ArticleEM: EventEmitter<Article> = new EventEmitter<Article>();
@ViewChild('copyArticleModal') public lgModal: ModalDirective;
@ViewChild('calculatorModal') public lgCalculatorModal;
constructor(private httpClient: HttpClient, private articlesService: ArticlesService, public agentsClientsService: AgentsClientsService, public peopleService: PeopleService,
private sessionService: SessionService, private _route: ActivatedRoute,
private notificationLGIService: NotificationLGIService, private datePipe: DatePipe, private domService: DomService) {
}
How can I do to make the modal visible even if I call the component from a dropdown menu?
from Append component view to body
No comments:
Post a Comment