I have created a form that adds input dynamically with an add and remove button. I would place them on the right
I can't click on remove button exept the lastet one
HTML file:
<mat-step [stepControl]="secondFormGroup">
<form [formGroup]="secondFormGroup">
<ng-template matStepLabel>Constituez votre équipe</ng-template>
<div formArrayName="pers" *ngFor="let control of secondFormGroup.controls.pers.controls; let i= index">
<mat-form-field>
<input matInput placeholder="Nom collaborateur #{{i+1}}" [formControl]="control.controls.name" required>
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Poste" [formControl]="control.controls.poste" required>
</mat-form-field>
<button *ngIf="secondFormGroup.controls.pers.controls.length > 1" (click)="deleteItem()" mat-mini-fab color="warn" class="rightButton"><mat-icon >remove</mat-icon>
</button>
</div>
<div>{{secondFormGroup.value | json}}</div>
<button (click)="addItem()" mat-mini-fab color="primary" class="rightButton"><mat-icon >add</mat-icon>
</button>
</form>
</mat-step>
CSS file :
.rightButton {
position: relative;
float: right;
}
When I disable rightButton class on the remove button , I could click on all of the buttons without a problem but they are not right positioned as I want.
Try this
.rightButton {
position: relative;
z-index: 99;
float: right;
}
This will make the button to be on top of all the HTML elements on the form. The z-index property only works on positioned elements (absolute, relative, fixed, and sticky)
For me z-index didnt work.
There was something in front of that button that is not visible. Making the button as a separate row helped.
In Bootstrap 4 this is how I made it a separate row:
<div class="row block-section">
<a data-placement="top" class="btn btn-sm btn-danger"
href="#" onclick="deleteClicked('video1');return false;">Delete </a>
</div>
Then it started working on mobile device even with
float: right
Related
select in an mat-expansion-panel. I am trying to get both of my ng-selects side by side, but even when I change the width. I can't seem to get them side by side. I went to some of documention and in one of the demos. They seem to use two ng-selects side by side. However, I think they are using boostrap to get that done. Does ngselect use boostrap as default or how can I get this down in material?
This is an example of what I am trying to achieve.
https://ng-select.github.io/ng-select#/forms
I tried changing the width this way:
.ng-select.AdditionalRecipientFormcustom ::ng-deep .ng-select-container {
width:30%;
}
<mat-expansion-panel [(expanded)]="xpandStatus" #formDirectiveTwo="ngForm" [formGroup]="AdditionalRecipientForm">
<mat-expansion-panel-header [collapsedHeight]="customCollapsedHeight" [expandedHeight]="customExpandedHeight" >
<mat-panel-title>
Add Recipients To The Report
</mat-panel-title>
</mat-expansion-panel-header>
<button mat-raised-button (click)="externalLogin()" color="primary" >Create Recipient</button>
<br>
<ng-select class="AdditionalRecipientFormcustom"
[items]="recipients"
[hideSelected]="true"
#select
loadingText="Loading..."
[selectOnTab] = "true"
dropdownPosition="auto"
bindLabel="Email"
placeholder="Select Recipient"
formControlName="UserRecipientsDto">
<ng-template ng-option-tmp let-item="item" let-search="searchTerm">
<div><span [ngOptionHighlight]="search">Email: {{item.Email}} </span><span>, </span><span [ngOptionHighlight]="search">Name: {{item.FirstAndLast }}</span></div>
</ng-template>
</ng-select>
<mat-form-field class="add-addtional-recipients-form-field">
<mat-label>Contact Name</mat-label>
<input matInput placeholder="User Email Address" formControlName="FirstAndLast">
</mat-form-field>
<ng-select class="AdditionalRecipientFormcustom"
[items]="recipientTypes"
[hideSelected]="true"
#select
loadingText="Loading..."
[selectOnTab] = "true"
dropdownPosition="auto"
bindLabel="typerecipient"
placeholder="Select Type Of Recipient"
formControlName="TaskRecipientTypeDto">
<ng-template ng-option-tmp let-item="item" let-search="searchTerm">
<div><span [ngOptionHighlight]="search">{{item.typerecipient}}</span></div>
</ng-template>
</ng-select>
<br>
<button mat-raised-button class="btnUpdate" (click)="resetFieldsForAdditionalForm()" [disabled]="!AdditionalRecipientForm.valid" color="primary"><b>Reset</b></button>
<button mat-raised-button class="btnReset" (click)="createNewRecipientUser(); this.getLogins(); " color="primary"><b>Update</b></button>
<br>
</mat-expansion-panel>
The problem is not specific to ng-select or material. I think you are not fully understanding the display property in css. The ng-select components end up on different lines because of the default display: block; styling. You can either give the ng-selects and the mat-form-field display: inline-block; or solve it with flexbox:
// apply this class to the parent element of the form controls (ng-select, ...)
.example-wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
}
// give ng-select a fixed width, because it isn't limited by the viewport width now
ng-select {
width: 200px;
}
For more detailed information on flexbox, see this link. Also, see a stackblitz example of what I've explained so far.
I'm trying to align a close icon for a BootstrapVue tab with Bootstrap 4.2 in the top right corner.
<b-tab v-for="order in tabs" :key="order.id">
<template slot="title">
<span class="float-left">{{ order.name }}</span>
<b-button type="button" class="close float-right" aria-label="Close" #click="closeTab(order.id)">
<span aria-hidden="true">×</span>
</b-button>
</template>
...content....
</b-tab>
However, not only does it not align right as expected, the tab appears cut off when focussed:
What I want is for that X to appear in the top right corner of the tab.
How do I do that and make the tab look normal when active?
If you are using BS4 then you can add this styling to make close button on top right
<button type="button" class="p-4 position-absolute top-0 right-0">
<span>×</span>
</button>
In this case css position property is your friend
template {
position: relative;
}
template button {
position: absolute;
right:0px;
}
Hello,
I use Angular 5 and material for my project, i'm trying to change the width of the autocomplete panel, with the exemple, i can now display the options corretly, but i cannot see all the informations for the options, then i modified the css file of the new component, but it doesn't work for the material component, can someone tell me how to do it, please?
This is the html of the component:
<mat-expansion-panel [expanded]="panelOpenState === true">
<mat-expansion-panel-header>
<mat-panel-title>
Critère de recherche
</mat-panel-title>
<mat-panel-description>
Saisir un numéro de procédure
</mat-panel-description>
</mat-expansion-panel-header>
<mat-form-field>
<input id="autocomplete" type="text" matInput placeholder="number" [ngControl]="inputControl"
[(ngModel)]="searchValue" [matAutocomplete]="auto" (keyup)="onChange()">
<mat-autocomplete #auto="matAutocomplete" class="class1">
<mat-option *ngFor="let procedure of filteredProcedures | async" [value]="procedure.procedureId">
<span>{{procedure.procedureId}} | </span>
<small>{{procedure.firstName}} </small>
<small>{{procedure.lastName}}</small>
<small>{{procedure.userId}}</small>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<button class="pull-right btn btn-info" (click)="search()">
<span matTooltip="Chercher une procédure">
<i class="fa fa-search"></i> Chercher </span>
</button>
</mat-expansion-panel>
And the css file:
.mat-button {
color: white
}
#autocomplete {
width: 400px, !important;
}
.class1 {
width: 400px, !important;
}
.cdk-overlay-pane {
width: 400px;
}
I have tried also to use :host, but it doesn't work.
:host ::ng-deep mat-autocomplete-panel(class1) {
width : 400px;
}
Can you tell me where is the error, please?
I want to display all/more informations of the options.
In fact, with the css file, the button style is applied correctly. but it doesn't work for the autocomplete panel, why?
Thank you.
Remove the commas from your css (then the width works) and you can't use :host as a pseudo since it's not a pseudo element. Pseudos list here: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
#autocomplete {
width: 400px !important;
}
.class1 {
width: 400px !important;
}
I have a button in angular 4 material table cell that I'd like to appear only when hover on table row:
<md-cell *cdkCellDef="let row" contenteditable='false' >
<div *ngIf="!row.editorEnabled" >{{row.goalStatusName}}
<button md-icon-button><md-icon (click)="row.editorEnabled=true;" mdTooltip="Edit">mode_edit</md-icon></button>
</div>
</md-cell>
How do I achieve this?
Update:
Entire code:
<md-cell *cdkCellDef="let row" contenteditable='false' >
<div *ngIf="!row.editorEnabled" >{{row.goalStatusName}}
<button md-icon-button><md-icon (click)="row.editorEnabled=true;" class="editButton" mdTooltip="Edit">mode_edit</md-icon></button>
</div>
<div *ngIf="row.editorEnabled" >
<md-input-container><input mdInput [(ngModel)]="row.goalStatusName" #goalName></md-input-container>
<button md-icon-button>
<md-icon (click)="modifyGoal(row.goalStatusId,row.goalStatusName)" mdTooltip="Save" style="color:green;font:bold;" >done</md-icon>
</button>
<button md-icon-button>
<md-icon (click)="row.editorEnabled=false" mdTooltip="Cancel" style="color:red;font:bold;" >clear</md-icon>
</button>
</div>
</md-cell>
button{ display:none}
md-cell:hover{
button{
display:block
}
}
.editButton{ visibility: hidden}
md-cell:hover .editButton{
visibility: visible;
}
This worked!
I've spent hours trying to get rid of the border radius on my select2 append checkbox. As of now the dropdown is displayed with a checkbox on the left. The problem is that there seems to be a border radius between the two input group elements, something similar to the image. The solution proposed was adding the input-group select2-bootstrap-prepend class to the wrapper element which doesn't work for me.
The html is as follows
<div class="col-lg-3">
<div class="panel-body">
<b>Region</b><br>
<div class="input-group select2-bootstrap-prepend">
<span class="input-group-addon">
<input type="checkbox" checked>
</span>
<select id="select2-single-append" class=" region">
</select>
</div>
</div>
</div>
View the running example from jsfiddle
you need
.select2-container--default .select2-selection--single {
border-radius:0 0.25rem 0.25rem 0;
}
see this fiddle
https://jsfiddle.net/grassog/kLchxehz/25/ (relevant css at the bottom of the css portion)