Unable to determine why the space appears in buttons in angular2 html - html

Initially my page appears like this, with one input text box and a "+" button and a "-" button.
Image -
Now, if i click on the "+" button , the size between the first text-box and button increases. Please have a look -
Image -
Please guide on why such a gap appears. This gap doesn't appear when i click on subsequent "+" buttons.
code -
app.component.html
<div *ngIf="addContainer">
<p style="margin-left: 200px; font-size:18px">Please enter the node -</p>
<table align="center">
<tbody>
<tr>
<td>
<input *ngIf="addMore" type="text" placeholder="Enter a Node" value="Aadhar">
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="addOneMore()" class="btn btn-success"> + </button>
</td>
<td>
<button type="button" style="margin-left: 10px" class="btn btn-danger"> - </button>
</td>
</tr>
<tr *ngFor="let container of containers" >
<div #myElement>
<td >
<input *ngIf="addMore" type="text" placeholder="Enter a Node" value="Aadhar">
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="addOneMore()" class="btn btn-success"> + </button>
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="myElement.remove()" class="btn btn-danger"> - </button>
</td>
</div>
</tr>
<tr>
<td style="text-align:center">
<button type="button" (click)="showGraphs()" class="btn btn-dark">Search</button>
</td>
</tr>
</tbody>
</table>
</div>

Its because of extra div inside the tr. replace the div by ng-container.
<tr *ngFor="let container of containers" >
<ng-container #myElement>
<td >
<input *ngIf="addMore" type="text" placeholder="Enter a Node" value="Aadhar">
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="addOneMore()" class="btn btn-success"> + </button>
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="myElement.remove()" class="btn btn-danger"> - </button>
</td>
</ng-container>
</tr>
OR
you can put the reference myElement at tr level
<tr *ngFor="let container of containers" #myElement >
<ng-container >
<td >
<input *ngIf="addMore" type="text" placeholder="Enter a Node" value="Aadhar">
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="addOneMore()" class="btn btn-success"> + </button>
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="myElement.remove()" class="btn btn-danger"> - </button>
</td>
</tr>

I did this -
app.component.ts
deleteOneMore(){
this.containers.splice(this.index, 1);
}
app.component.html
<tr *ngFor="let container of containers; let i = index;" >
<ng-container >
<td >
<input *ngIf="addMore" type="text" placeholder="Enter a Node" value="Aadhar">
</td>
<td >
<button type="button" style="margin-left: 10px" (click)="addOneMore()" class="btn btn-success"> + </button>
</td>
<td>
<button type="button" style="margin-left: 10px" (click)="deleteOneMore()" class="btn btn-danger"> - </button>
</td>
</ng-container>
</tr>

So here is my answer i think it will help you with your problem, you have used a class in every button called "btn" and it contain by default padding of padding: .375rem .75rem; so you guess my answer, you have to remove it and you will be fine.
when padding were not removed from btn class
when padding removed from btn classjust checked after commenting this btn padding in picture

Related

IMemoryCache without MVC

From this code, which takes data from a database, I extract the fields that interest me and show them to the video.
#foreach (var item in Model.ProductList)
{
<tr>
<td onclick="myFunction(this)" class="view-message dont-show"><h5>#item.Id</h5></td>
<td onclick="myFunction(this)" class="view-message"><h5>#item.Name</h5></td>
<td onclick="myFunction(this)"><h4 style="margin-top: 5px;"><span class="label label-success ">#item.Model</span></h4></td>
<td onclick="myFunction(this)" class="view-message text-left"><h5>#item.Price</h5></td>
<td>
<form method="post">
<span class="btn-group pull-right" style="margin-top: 5px">
<a class="btn btn-warning btn-xs" asp-page="/Product/Edit" asp-route-id="#item.Id" style="background-color: green; height: 29px; margin-top: -1px;">
<i class="glyphicon glyphicon-edit"></i>
</a>
<button type="submit" class="btn btn-danger btn-xs" asp-page-handler="Delete" asp-route-id="#item.Id" style="height: 27px; margin-top: 0px;"
onclick="return confirm('Are you sure to delete this product?');">
<i class="glyphicon glyphicon-remove"></i>
</button>
</span>
</form>
</td>
</tr>
}
Question: How can I enter this data in cache (IMemoryCache)?
I use Core 2.1 and I would like to avoid using MVC and then using "controllers".
Thanks in advance for your help.

Placing button next to input in table row

This is what my table looks right now
Table:
I'm trying to place the small x button aligned next to the input textbox. Here's my code so far.
<table class="table table-hover">
<thead class="thead-inverse">
<th>Clave</th>
<th>Razón social</th>
<th>Contacto 1</th>
<th>Contacto 2</th>
<th>Contacto 3</th>
<th></th>
</thead>
<tbody>
<td class="col-md-1">
<input type="text" name="" class="form-control"/>
</td>
<td class="col-md-3">
<input type="text" name="" class="form-control"/>
</td>
<td>
<input type="text" name="" class="form-control" disabled/>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
<td>
<input type="text" name="" class="form-control" disabled/>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
<td>
<input type="text" name="" class="form-control" disabled/>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
<td>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
</tbody>
</table>
here is what you're looking for
td .btn {
position: absolute;
margin-top: 7px;
float: right;
margin-left: 5px;
}
td input {
float: left;
}
.spacer {
padding-left: 30px !important;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-hover">
<thead class="thead-inverse">
<th>Clave</th>
<th>Razón social</th>
<th>Contacto 1</th>
<th>Contacto 2</th>
<th>Contacto 3</th>
<th></th>
</thead>
<tbody>
<td class="col-md-1">
<input type="text" name="" class="form-control"/>
</td>
<td class="col-md-3">
<input type="text" name="" class="form-control"/>
</td>
<td>
<input type="text" name="" class="form-control" disabled/>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
<td class="spacer">
<input type="text" name="" class="form-control" disabled/>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
<td class="spacer">
<input type="text" name="" class="form-control" disabled/>
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
<td class="spacer">
<a title="Quitar" class="btn btn-danger btn-xs"><span class="fa fa-times"></span></a>
</td>
</tbody>
</table>
Have you tried:
<td nowrap></td>
There is a CSS version of this:
th {
white-space: nowrap;
}

How to remove empty space in a div element?

Here I am providing a screenshot and I outlined the area I wanted to collapse all the way to just right after the last blue buttom, touching it. I outlined the area I wanted to collapse in red. Is there a specific class that will let me do that?
Ty
code:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="panel panel-primary col-md-6">
<div class="row">
<!-- Label -->
<button type="button" class="btn btn-info btn-xs btn-block" id='invoicelabel'><strong>Invoice CP</strong>
</button>
<!-- Invoice CP -->
<div class="btn-group btn-group-vertical col-md-3 test2">
<button class="btn btn-primary btn-sm" type="submit">Total Amount</button>
<button class="btn btn-primary btn-sm" type="submit">Duplicate</button>
<button class="btn btn-primary btn-sm" type="submit">Clear</button>
<button class="btn btn-primary btn-sm" type="submit">Currency</button>
<button class="btn btn-primary btn-sm" type="submit" disabled>.</button>
<button class="btn btn-primary btn-sm" type="submit" disabled>.</button>
</div>
<table class="table table-condensed">
<tbody class="col-md-10 test pull-right">
<tr>
<td class="default" width="20%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Pieces">
</td>
<td class="default" width="35%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Unit Price">
</td>
<td class="default" width="45%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Line Amount">
</td>
</tr>
<tr>
<td class="default" width="20%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Pieces">
</td>
<td class="default" width="35%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Unit Price">
</td>
<td class="default" width="45%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Line Amount">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Try checking the CSS height property of the .test or .test2. Probably it is set to a specific value. If you leave it blank, the area will fit to the content.

Angular Datepicker displaying twice in bootstrap modal

I'm new to Angular JS. I was working with Angular JS calendar and am trying to display the angular Datepicker inside Bootstrap modal window. However the Datepicker is displayed twice as shown in the image below.
Here's my modal html code.
<div class="modal-header">
<h3 class="modal-title">{{ vm.event.event.title }}</h3>
</div>
<div class="modal-body" ng-repeat="event in vm.event track by $index">
<h3 class="post-subtitle">
{{event.type}}
</h3>
<table class="table table-bordered">
<thead>
<th>Starts on</th>
<th>Ends on</th>
</thead>
<tbody>
<td>
<p class="input-group" style="max-width: 250px">
<input
type="text"
class="form-control"
readonly
uib-datepicker-popup="dd MMMM yyyy"
ng-model="event.startsAt"
is-open="event.startOpen"
close-text="Close" >
<span class="input-group-btn">
<button
type="button"
class="btn btn-default"
ng-click="vm.object.toggle($event, 'startOpen', event)">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
<uib-timepicker
ng-model="event.startsAt"
hour-step="1"
minute-step="15"
show-meridian="true">
</uib-timepicker>
</td>
<td>
<p class="input-group" style="max-width: 250px">
<input
type="text"
class="form-control"
readonly
uib-datepicker-popup="dd MMMM yyyy"
ng-model="event.endsAt"
is-open="event.endOpen"
close-text="Close">
<span class="input-group-btn">
<button
type="button"
class="btn btn-default"
ng-click="vm.object.toggle($event, 'endOpen', event)">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
<uib-timepicker
ng-model="event.endsAt"
hour-step="1"
minute-step="15"
show-meridian="true">
</uib-timepicker>
</td>
</tbody>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="$close()">OK</button>
</div>

Spanning columns [HTML]

I'm developing a hybrid-app w/ Cordova. In my index.html I have the following code:
<div class="container">
<table style="width:100%;height:100%;border-spacing:3px;border-collapse: separate;">
<tr style="height:15%;width:100%">
<td style="width:33%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:33%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:33%" colspan="3">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
</tr>
<tr style="height:15%;width:100%">
<td style="width:25%">
<button class="btn btn-default"style="width:100%" type="button">OK</button>
</td>
<td style="width:25%">
<button class="btn btn-default" style="width:100%"type="button">OK</button>
</td>
<td>
<button class="btn btn-default" style="width:100%"type="button">OK</button>
</td>
<td>
<button class="btn btn-default" style="width:100%"type="button">OK</button>
</td>
</tr>
</table>
Don't care about the Bootstrap things, the main thing is the <td> tags in the second <tr>.
Change your 1:st tr's last td's to <td style="width:33%" colspan="2"> and both rows will be equal wide.
<div class="container">
<table style="width:100%;height:100%;border-spacing:3px;border-collapse: separate;">
<tr style="height:15%;width:100%">
<td style="width:33%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:33%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:33%" colspan="2">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
</tr>
<tr style="height:15%;width:100%">
<td style="width:25%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:25%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td>
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td>
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
</tr>
</table>
</div>
Nevermind, this is what I wanted. I figured it out :)
<div class="container">
<table style="width:100%;height:100%;border-spacing:3px;border-collapse: separate;">
<tr style="height:15%;width:100%">
<td style="width:33%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:33%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:33%" >
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
</tr>
</table>
<table style="width:100%">
<tr style="height:15%;width:100%">
<td style="width:25%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:25%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:25%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
<td style="width:25%">
<button class="btn btn-default" style="width:100%" type="button">OK</button>
</td>
</tr>
</table>
</div>