5

I have created global popup components.I want to set width and height anf title dynamically.How do it? modal:

<app-m [(visible)]="show" title="Modal" data-popup="width:300;height:250">
<h1>Sample Title 1</h1>
<button (click)="show= !show" class="btn">Close</button>
</app-m>

1 Answer 1

9

You can do it with decorators. Pass height, width and title model to <app-dialog> like this:

Now in dialog.component.html should be:

<div [@modal] *ngIf="visible" class="dialog" [ngStyle]="{'width': width+'px', 'height': height+'px'}">
    <b>{{title}}</b>
    <ng-content></ng-content>
    <button *ngIf="closable" (click)="close()" aria-label="Close" class="cls">X</button>
</div>
<div *ngIf="visible" class="overlay" (click)="close()"></div>
Sign up to request clarification or add additional context in comments.

17 Comments

Working Good..Thanks
Sanoj..I have one more question?
@AppleOrange yes, can you share??
Sanoj: How we can create own jshint?
Sanoj: From your example link How we can write code(in typescript) for open same like for close. After i click button i want to open particular popup.How do it?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.