How to remove form when Mat-stepper index changes - html

I am using this Stackblitz example to dynamically create forms in mat-stepper.
I have 3 steppers Personal Details, Address and Contact.
However, when I open the Address form and then switch to contact I want the address form to disappear.
Below is my code. Can someone help me to point out my mistake?
Code for Mat-stepper in HTML
<mat-step label="Personal Details" state="chat">
<div class="col-sm-offset-10">
<button mat-icon-button color="primary" matTooltip="Create New Form" (click)="addPersonalDetails()">
<mat-icon aria-label="Example icon-button with a heart icon">add_circle_outline</mat-icon>
</button>
</div>
<div>
<hr />
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Address" state="chat">
<div class="col-sm-offset-10">
<button mat-icon-button color="primary" matTooltip="Create New AddressForm" (click)="addAddress()">
<mat-icon aria-label="Example icon-button with a heart icon">add_circle_outline</mat-icon>
</button>
</div>
<div>
<hr />
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Contact" state="chat">
<div class="col-sm-offset-10">
<button mat-icon-button color="primary" matTooltip="Create New Contact Form" (click)="addContact()">
<mat-icon aria-label="Example icon-button with a heart icon">add_circle_outline</mat-icon>
</button>
</div>
<div>
<hr />
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
Typescript Code
addPersonalDetails() {
this.service.setRootViewContainerRef(this.viewContainerRef);
this.service.addDynamicPersonalComponent();
}
addAddress() {
this.service.setRootViewContainerRef(this.viewContainerRef);
this.service.addDynamicAddressComponent();
}
addContact() {
this.service.setRootViewContainerRef(this.viewContainerRef);
this.service.addDynamicContactComponent();
}
The Typescript code calls the address, Personal Details, and other components.
Now if I click on add form button for address and then switch to contact stepper I want to hide the address form and display the contact form.
Currently, the address from stays there and the contact form is displayed below it.
Currently this is how the page looks in my app
If I change tabs I should be able to hide and show forms seperately for each stepper option.

Related

Create an input link in the button

How can I input a link in the button when I press the button?
<div class="buttons">
<span class="sold-out-tag position-top-right">Best Seller</span>
<button class="btn custom-btn position-bottom-right"> Add to cart</button>
</div>
Also you can trigger a link by JavaScript.
<button
onclick="window.location(this.getAttribute('data-link'))"
data-link="/hello">go to hello</button>
One way could be to use an anchor tag instead of the button and make it look like a button.
HTML:
<div class="buttons">
<a class="btn custom-btn position-bottom-right"> Add to cart</a>
</div>
CSS:
.custom-btn {
border: medium dashed green;
}
Alternatively, you could do:
<button class="btn custom-btn position-bottom-right" onclick="location.href='yourlink.com';"> Add to Cart </button>
Try this:
<a href='http://my-link.com'>
<button class="GFG">
Click Here
</button>
</a>
You can use the anchor tag and provide a Bootstrap class for the button, like,
<a class="btn btn-success" href="link"> Add to Cart</a>
If the label "Add to cart" matches the expectations, we'd be talking about a form. A form that causes an element to be added typically uses the POST method:
<form class="buttons" method="post" action="/path/to/add/to/cart/script">
<input type="hidden" name="product" value="123">
<span class="sold-out-tag position-top-right">Best Seller</span>
<button class="btn custom-btn position-bottom-right"> Add to cart</button>
</form>
Alternatively, there's GET as well:
<form class="buttons" method="get" action="/path/to/add/to/cart/script?product=123">
<span class="sold-out-tag position-top-right">Best Seller</span>
<button class="btn custom-btn position-bottom-right"> Add to cart</button>
</form>
Since GET doesn't carry additional payload, you'll get the same effect with a regular anchor:
Add to cart
You don't want search engine spiders to populate carts, so you typically leave GET for data fetching.

Angular: Add value to input from onClick event button

I'm trying to make an Edit Modal using Angular. the td fields get a value from this table and send it to a modal using the (click) event
<tbody>
<tr *ngFor="let mascota of mascotas" class="text-center ">
<td>{{mascota.name}}</td>
<td>{{mascota.birthDate}}</td>
<td>{{mascota.species.name}}</td>
<td>
<button class="btn btn-info mx-2">Detalles</button>
<button class="btn btn-warning mx-2" (click)="openSM(contenido,mascota)">Editar</button>
<button class="btn btn-danger mx-2">Remover</button>
</td>
</tr>
</tbody>
This is the function that I made in the component, used a const in order to get the values and send it to the modal
openSM(contenido, mascota) {
const modalRef = this.modal.open(contenido,{size:'lg',centered:true});
modalRef["mascota"] = mascota;
console.log(modalRef);
}
And this is the modal where I'm tying to get the value
<ng-template #contenido let-modal>
<div class="modal-header">
<h4 class="modal-title">Editar datos de mascota</h4>
<button class="close" aria-label="close" type="button" (click)="modal.close()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="form-horizontal form-material" id="editform" autocomplete="off">
<div class="form-group m-t-10">
<div class="col-sm-10">
<label>Nombre de Mascota:</label>
<input class="form-control" type="text" placeholder="Nombre" value="mascota.name" />
</div>
</div>
</form>
</div>
</ng-template>
But when I click on the Edit button it didn't recognize the value
And when I used {{}} the const get an 'undefined' value
Error from Inspect Element
Contenido Data
Is there any way to get that value and put it into the input tag? I want to do the same with the others td fields, but first this needs to work well
Console log of the inputs in the constructor

Panel in angular material design

I want to create a panel like above using angular 6 material design.
Use the below code
<mat-card>
<mat-card-header>
<div class="col-lg-12">
<div class="col-lg-9">
<h3>{{ pageTitle }}</h3>
</div>
<div class="col-lg-3">
<button mat-raised-button color="primary" [disabled]="!form.valid" (click)="form.ngSubmit.emit()">Save</button>
<button type="reset" mat-raised-button color="accent" (click)="cancelForm()">Cancel</button>
</div>
</div>
</mat-card-header>
<mat-progress-bar mode="indeterminate" *ngIf="progress"></mat-progress-bar>
<mat-divider></mat-divider>
<mat-card-content>
<mat-form-field>
<input matInput placeholder="Name [(ngModel)]="vehicleMakeViewModel.name" name="name" required #name="ngModel"></mat-form-field>
</mat-card-content>
</mat-card>
The above code produce the below template. The title and buttons are not properly align to the template.
I am not sure but it could be that you have not imported the styles for angular material (or that you have a different style, not the default one).
Try adding this to your styles.css
#import "~#angular/material/prebuilt-themes/indigo-pink.css";
info here
https://material.angular.io/guide/getting-started
also for info on themes:
https://material.angular.io/guide/theming

Angular 2 Nested Modal Dialog with PrimeNG doesn't work

I am using the PrimeNG dialog component and I have a modal dialog from which, on the click of a button, I want to show another modal dialog.
What is happening is that my second modal dialog is not really modal, because I only see the content of the dialog following the button.
I do change [appendTo] attribute of the p-dialog for the second modal dialog but it does not seem to work properly.
How can I open nested dialog in a p-dialog?
Dialog in a angular 2 component:
<p-dialog header="Create/Edit Financial Flow" [visible]="display$ | async" modal="modal" width="500" height="600" responsive="true" [resizable]="false" [closable]="false">
<financial-flowdialog #myfinancialflowdialog (onCloseDialog) ="closeDialog()" [flowdata]="selectedFlows$ | async"></financial-flowdialog>
</p-dialog>
When clicking a button within the first modal dialog, should open a second dialog. Below the definition of the nested dialog:
<p-dialog header="Title" [(visible)]="display" [appendTo]="body" *ngIf="display" modal="modal" width="500" height="600" responsive="true"
[resizable]="false" [closable]="false">
<div class="container-fluid">
<form (ngSubmit)="onSubmit()">
<div class="pull-right top-buffer ">
<button type="button" class="btn btn-primary" (click)="closeDialog()">Cancel</button>
<button type="submit" class="btn btn-primary">Select</button>
</div>
</form>
</div>
</p-dialog>
<button type="button" #mybtn [value]="value" ngDefaultControl [formControlName]="key" [id]="key" [ngStyle]="style" (click)="openDialog()">{{label}}</button>
I can open the first dialog but when I click on the button to open the second dialog, the content of dialog shows up like a normal div. Below the html rendered:
<section>
<div id="nestediag" ng-reflect-form="[object Object]" class="ng-pristine ng-invalid ng-touched">
<!--template bindings={
"ng-reflect-ng-if": "true"
}--><p-dialog header="Title" height="600" modal="modal" responsive="true" width="500" ng-reflect-visible="true">
<div class="container-fluid">
<form class="ng-untouched ng-pristine ng-valid">
<div class="pull-right top-buffer ">
<button class="btn btn-primary" type="button">Cancel</button>
<button class="btn btn-primary" type="submit">Select</button>
</div>
</form>
</div>
</p-dialog>
<button ngdefaultcontrol="" type="button" value="Select a payee" ng-reflect-name="flowpayee" ng-reflect-ng-style="[object Object]" ng-reflect-value="Select a payee" ng-reflect-id="flowpayee" id="flowpayee" class="ng-pristine ng-valid ng-touched" style="width: 100%;">Select a payee</button>
</div>
</section>
You can solve this problem by appending the second dialog to the document body by using the appendTo attribute, e.g.
<p-dialog appendTo="body">
...
</p-dialog>
Defining a componentref variable and using [appendTo]="Componentref" solve the issue.
See discussion https://github.com/primefaces/primeng/issues/656
You can solve this problem by appending the second dialog to the document body by using the appendTo attribute, for e.g.
<p-dialog appendTo="body">
.............
</p-dialog>

HTML/CSS Span Tag causing Bootstrap Modal Footer buttons to lower

On my website I used a span tag to pull a button and a text input left from the footer of a twitter bootstrap modal display, the pictures will show this.
For some reason the two buttons on the left and lower than the two on the right, how can I raise the two on the left?
HTML:
CSS:
.modal-footer .floatLeft {
float: left;
}
HTML:
<div class="modal-footer">
<span class="floatLeft">
<input placeholder="out of" class='changeMaxMark' style='margin-top:9px;'id='maxMarkBox' name='maxMarkBox' type='text'>
<button id='changeMaxMark' name='changeMaxMark' class='btn btn-success'> Set All </button>
</span>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" id="markSave" onClick="togleMarkSave()">Save Changes</button>
</div>
link to picture 1(http://snag.gy/i5FRT.jpg)
link to picture 2(http://snag.gy/2Y9Q2.jpg)
First of all remove the span. Bootstrap has specific CSS classes to pull things left. pull-left which I added to the first two elements.
The edited HTML is this:
<div class="modal-footer">
<input placeholder="out of" class='changeMaxMark pull-left' id='maxMarkBox' name='maxMarkBox' type='text'>
<button id='changeMaxMark' name='changeMaxMark' class='btn btn-success pull-left'> Set All </button>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" id="markSave" onClick="togleMarkSave()">Save Changes</button>
</div>
You also had a specific style on the input field to push margin-top down 9px that is unecessary.
No custom CSS classes or additional markup is necessary.
Here is the working JSFiddle