Inserting component on click between grid rows positioning - css

I have the exact same issue depicted in this post(link attached below), the only difference is that I can't seem to get the positioning correct for the new element. Currently, my element just inserts at the end of the grid instead of below the card clicked.
Inserting component on click between grid rows
I have been trying to use the ID and row index of each card to hopefully get the new element to drop below the card that was clicked.
in the code below I am trying to append the on button click to a specific card based on its ID
<div fxFlex class="grid-container">
<div
class="grid-item card"
*ngFor="let x of fleetVehicles; let i = index;"
[id]="x.id"
(click)="toggleCard(i + 1, x.id)"
>
<div class="inside-card">
<header>
<header>Audi {{ x.id }}</header>
</header>
<article>
<div>
<img src="assets/images/audi.png" style="width: 80%; height: 70%" />
</div>
<div>
<footer>HVC 529 EC</footer>
</div>
<!-- <div
kind="highlight"
[class]="collapse ? 'dropdown' : 'gsMDEi'"
></div> -->
</article>
</div>
</div>
<li *ngIf="collapse" id="confirmBooking" class="accordion">
<div class="card-dropdown" style="flex-direction: row; display: flex">
<div fxFlex="60" style="width: 100%; height: 100%">
<header class="dropdown-header">Audi</header>
<article>
<div style="padding: 26px;">
<div class="icon-pos">
<div class="p-info">
<i class="fas fa-door-open icon-style"></i>Doors
</div>
<div class="p-info">
<i class="fas fa-users icon-style"></i>Seats
</div>
<div class="p-info">
<i class="fas fa-gear icon-style"></i>Manual
</div>
<div class="p-info">
<i class="far fa-snowflake icon-style"></i>A/C
</div>
</div>
<div style="height: 100%; width: 100%;">
<img src="assets/images/audi.png" style="width: 75%;"/>
</div>
</div>
<footer style="height: 50px;">
<div class="dropdown-footer">HVC 529 EC</div>
</footer>
</article>
</div>
<div fxFlex="40" style="width: 70%; height: 100%; text-align: -webkit-center">
<div style="height: 100%; display: flex; justify-content: center">
<form style="width: 50%; margin: 6px;">
<label for="Vehicle">Vehicle</label>
<input
type="text"
id="Vehicle"
name="Vehicle"
placeholder="Vehicle"
/>
<label for="Name">Name</label>
<input
type="text"
id="Name"
name="Name"
placeholder="Enter your name"
/>
<label for="Start Date">Start Date</label>
<input matInput type="datetime-local" />
<br />
<label for="End date">End date</label>
<input matInput type="datetime-local" />
<br />
<label for="Customers">Customers</label>
<select id="Customers" name="country">
<option value="australia">VW</option>
<option value="canada">Audi</option>
<option value="usa">Mercedes</option>
</select>
<label for="Passengers">Passengers</label>
<select id="Passengers" name="country">
<option value="australia">1</option>
<option value="canada">2</option>
<option value="usa">3</option>
</select>
<label for="Personal Tracker">Personal Tracker</label>
<input
type="text"
id="Personal Tracker"
name="Personal Tracker"
placeholder="If you have a personal tracker, enter the tracking number"
/>
<label for="Floater">Floater Tracker</label>
<select id="Floater" name="country">
<option value="" disabled selected style="text-color: grey">
If you don not have a personal tracker, select a floater
</option>
<option value="australia">Anel</option>
<option value="canada">Andrew</option>
<option value="usa">Nico</option>
</select>
<button type="submit" class="sub-button" (click)="makeBooking()">Submit</button>
<button type="submit" class="can-button" (click)="cancelBooking()">Cancel</button>
</form>
</div>
</div>
</div>
</li>
</div>
here is my typescript for each card that will be displayed based on the fleetVehicles array. in the toggle card function is where I am needing to have the display on click.
fleetVehicles = [
{ id: 1, name: 'Marc' },
{ id: 2, name: 'Marc' },
{ id: 3, name: 'Marc' },
{ id: 4, name: 'Marc' },
{ id: 5, name: 'Marc' },
{ id: 6, name: 'Marc' },
{ id: 7, name: 'Marc' },
{ id: 8, name: 'Marc' },
{ id: 9, name: 'Marc' },
{ id: 10, name: 'Marc' },
{ id: 11, name: 'Marc' },
{ id: 12, name: 'Marc' },
];
collapse = false;
selectedRowIndex!: number;
toggleCard(row: number, id: number) {
this.selectedRowIndex = row;
console.log(row);
// this.model = {
// columnId: Array.from(
// this.renderer.parentNode(this.column).children
// ).indexOf(this.column),
// width: this.width,
// };
// console.log(this.model);
if ((row = id)) {
// this.collapse = !this.collapse;
document.getElementById('confirmBooking');
// b?.style.display="block";
}
console.log(this.fleetVehicles.find((x) => x.id == id));
}

Related

Angular PrimeNG. PrimeFlex: input field not behaving as expected

I am working on an Angular 7 application using PrimeNG and Primeflex. While trying to style a form based component, I have trouble with <input pInputText ...> elements not respecting the prime-flex styling (or at least not behaving as I would expect).
Summary of issue
(Variant 1)
I am enclosing both a <label> and <input> element in two nested <div> elements which are styled with class="p-grid" and class="p-col-*".
<div class="p-grid">
<div class="p-col-8">
<label for="description">Description</label><br/>
<input id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label for="numeric">Numeric</label><br/>
<input id="numeric" pInputText formControlName="numeric">
</div>
</div>
I was expecting the <input> field to grow/shrink with the available space, but it seems to have a fixed width that does not adjust to the available space or the number of columns I am using.
(Variant 2)
I then tried nesting another p-gridelement within the column-div and giving each element the full width:
<div class="p-grid">
<div class="p-col-8">
<div class="p-grid">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
</div>
<div class="p-col-4">
<div class="p-grid">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
</div>
This does indeed make the <input> field grow to use the available outer column space, but somehow destroys the margin between the columns/fields.
(Variant 3)
After some experimenting I have come up with a solution that does what I want, but it uses incorrect nesting of prime flex classes:
<div class="p-grid">
<div class="p-col-8">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
This lets the fields grow/shrink in size according to the outer column configuration and maintains the margin between fields/columns. However, as this seems to violate the nesting rules of primeflex as I understood them, I am uncertain if this is indeed the correct way to do this.
Detailed working example showing the problem
The working example can also be found on stackblitz.
Here is a complete working example, based on a default angular project (created with ng new demo):
Modifications to dependencies in package.json
(npm i --save primeflex primeicons primeng)
"primeflex": "^1.0.0-rc.1",
"primeicons": "^1.0.0",
"primeng": "^8.0.0-rc.1"
Modifications to angular.json
"styles": [
'node_modules/primeicons/primeicons.css',
'node_modules/primeng/resources/primeng.min.css',
'node_modules/primeflex/primeflex.css',
'node_modules/primeng/resources/themes/nova-light/theme.css',
"src/styles.css"
],
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import {FormsModule, ReactiveFormsModule} from '#angular/forms';
import {PanelModule} from 'primeng/panel';
import {AutoCompleteModule} from 'primeng/autocomplete';
import {BrowserAnimationsModule} from '#angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { ListComponent } from './list.component';
import { DetailComponent } from './detail.component';
import { LeftComponent } from './left.component';
import { RightComponent } from './right.component';
#NgModule({
declarations: [
AppComponent,
ListComponent,
DetailComponent,
LeftComponent,
RightComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
PanelModule,
AutoCompleteModule,
FormsModule,
ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-root',
template: `
<ng-container>
<h3>Title</h3>
<div class="container">
<app-list></app-list>
<app-detail></app-detail>
</div>
</ng-container>`,
styles: [`
div.container {
display: flex;
flex-wrap: nowrap;
}
app-list {
flex: 0 0 auto;
}
app-detail {
flex: 1 0 auto;
}`
]
})
export class AppComponent {
title = 'demo';
}
list.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-list',
template: `
<p-panel [header]="'List'">
<div class="item" *ngFor="let item of items">
<div>{{item}}</div>
</div>
</p-panel>`
})
export class ListComponent {
items: string[] = ['Item 1', 'Item 2', 'Item 3'];
}
detail.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-detail',
template: `
<div class="left">
<p-panel [header]="'Left'">
<app-left></app-left>
</p-panel>
</div>
<app-right></app-right>`,
styles: [':host { display: flex; } div.left{ flex: 1 0 auto; padding: 0 15px; } app-right { flex: 0 1 50%; }']
})
export class DetailComponent {
}
left.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-left',
template: '<p>left works!</p>'
})
export class LeftComponent {
}
right.component.ts
(Choose which version of right*.component.html by uncommenting the correct lines. The order of these correspond to the order I used to present my three approaches above)
import { Component, OnInit } from '#angular/core';
import {FormBuilder, FormGroup} from '#angular/forms';
#Component({
selector: 'app-right',
// --> choose variant by activating one of the three following lines
templateUrl: './right1.component.html'
// templateUrl: './right2.component.html'
// templateUrl: './right3.component.html'
})
export class RightComponent implements OnInit {
form: FormGroup;
items: string[] = ['Austria','France','Germany','Italy','Liechtenstein','Switzerland'];
constructor(private fb: FormBuilder) { }
ngOnInit() {
this.form = this.buildForm();
this.fillForm();
}
buildForm(): FormGroup {
return this.fb.group({
id1: [{value: '', disabled: true}],
id2: [{value: '', disabled: true}],
id3: [{value: '', disabled: true}],
auto: [{value: '', disabled: true}],
description: [{value: '', disabled: true}],
numeric: [{value: '', disabled: true}],
field1: [{value: '', disabled: true}],
field2: [{value: '', disabled: true}],
field3: [{value: '', disabled: true}],
field4: [{value: '', disabled: true}]
});
}
fillForm() {
this.form.controls.id1.setValue('42');
this.form.controls.id2.setValue('666');
this.form.controls.id3.setValue('314152');
this.form.controls.auto.setValue('Germany');
this.form.controls.description.setValue('Short text');
this.form.controls.numeric.setValue('2345');
this.form.controls.field1.setValue('foo');
this.form.controls.field2.setValue('bar');
this.form.controls.field3.setValue('baz');
this.form.controls.field4.setValue('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
}
}
right1.component.html (Variant 1)
<p-panel [header]="'Right 1'">
<form [formGroup]="form" class="container">
<div class="p-grid">
<div class="p-col-12">
<label for="id">ID</label>
<div>
<input pInputText id="id" formControlName="id1">
<input pInputText formControlName="id2">
<input pInputText formControlName="id3">
</div>
</div>
</div>
<h3>Grouped Information</h3>
<div class="p-grid">
<div class="p-col-12">
<label for="auto">Autocomplete</label>
<p-autoComplete
id="auto"
formControlName="auto"
[suggestions]="items"
[style]="{width: '100%'}">
</p-autoComplete>
</div>
</div>
<div class="p-grid">
<div class="p-col-8">
<label for="description">Description</label><br/>
<input id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label for="numeric">Numeric</label><br/>
<input id="numeric" pInputText formControlName="numeric">
</div>
</div>
<h3>More grouped information</h3>
<div class="p-grid">
<div class="p-col-3">
<label for="field1">Field 1</label><br/>
<input id="field1" pInputText formControlName="field1">
</div>
<div class="p-col-3">
<label for="field2">Field 2</label><br/>
<input id="field2" pInputText formControlName="field2">
</div>
<div class="p-col-3">
<label for="field3">Field 3</label><br/>
<input id="field3" pInputText formControlName="field3">
</div>
<div class="p-col-3">
<label for="field4">Field 4</label><br/>
<input id="field4" pInputText formControlName="field4">
</div>
</div>
</form>
</p-panel>
right2.component.html (Variant 2)
<p-panel [header]="'Right 2'">
<form [formGroup]="form" class="container">
<div class="p-grid">
<div class="p-col-12">
<label for="id">ID</label>
<div>
<input pInputText id="id" formControlName="id1">
<input pInputText formControlName="id2">
<input pInputText formControlName="id3">
</div>
</div>
</div>
<h3>Grouped Information</h3>
<div class="p-grid">
<div class="p-col-12">
<label for="auto">Autocomplete</label>
<p-autoComplete
id="auto"
formControlName="auto"
[suggestions]="items"
[style]="{width: '100%'}">
</p-autoComplete>
</div>
</div>
<div class="p-grid">
<div class="p-col-8">
<div class="p-grid">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
</div>
<div class="p-col-4">
<div class="p-grid">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
</div>
<h3>More grouped information</h3>
<div class="p-grid">
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field1">Field 1</label>
<input class="p-col-12" id="field1" pInputText formControlName="field1">
</div>
</div>
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field2">Field 2</label>
<input class="p-col-12" id="field2" pInputText formControlName="field2">
</div>
</div>
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field3">Field 3</label>
<input class="p-col-12" id="field3" pInputText formControlName="field3">
</div>
</div>
<div class="p-col-3">
<div class="p-grid">
<label class="p-col-12" for="field4">Field 4</label>
<input class="p-col-12" id="field4" pInputText formControlName="field4">
</div>
</div>
</div>
</form>
</p-panel>
right3.component.html (Variant 3)
<p-panel [header]="'Right 3'">
<form [formGroup]="form" class="container">
<div class="p-grid">
<div class="p-col-12">
<label for="id">ID</label>
<div>
<input pInputText id="id" formControlName="id1">
<input pInputText formControlName="id2">
<input pInputText formControlName="id3">
</div>
</div>
</div>
<h3>Grouped Information</h3>
<div class="p-grid">
<div class="p-col-12">
<label for="auto">Autocomplete</label>
<p-autoComplete
id="auto"
formControlName="auto"
[suggestions]="items"
[style]="{width: '100%'}">
</p-autoComplete>
</div>
</div>
<div class="p-grid">
<div class="p-col-8">
<label class="p-col-12" for="description">Description</label>
<input class="p-col-12" id="description" pInputText formControlName="description">
</div>
<div class="p-col-4">
<label class="p-col-12" for="numeric">Numeric</label>
<input class="p-col-12" id="numeric" pInputText formControlName="numeric">
</div>
</div>
<h3>More grouped information</h3>
<div class="p-grid">
<div class="p-col-3">
<label class="p-col-12" for="field1">Field 1</label>
<input class="p-col-12" id="field1" pInputText formControlName="field1">
</div>
<div class="p-col-3">
<label class="p-col-12" for="field2">Field 2</label>
<input class="p-col-12" id="field2" pInputText formControlName="field2">
</div>
<div class="p-col-3">
<label class="p-col-12" for="field3">Field 3</label>
<input class="p-col-12" id="field3" pInputText formControlName="field3">
</div>
<div class="p-col-3">
<label class="p-col-12" for="field4">Field 4</label>
<input class="p-col-12" id="field4" pInputText formControlName="field4">
</div>
</div>
</form>
</p-panel>
Screenshots illustrating the issue
Variant 1 (not growing/shrinking)
Variant 2 (growing/shrinking but missing margins)
Variant 3 (working but invalid nesting)
Add
style="width: 100%;"
To your inputs in right1.component.html (or define/use a class with width of 100%), for example:
<input id="description" style="width: 100%;" pInputText formControlName="description">
An input by default is size=20, and is not going to take up the width of the div. The p-col div is growing appropriately, just not the input inside it.

Bootstrap 4: validation breaks styling on inline form elements?

I am trying to validate an inline form field, with Bootstrap 4.
When validation is triggered, the inline form field jumps in width. Here is a fiddle (just click Enter without entering a value, to see the problem): https://jsfiddle.net/aq9Laaew/213418/
How can I fix this?
This is my HTML:
<form class="form-inline needs-validation" id="form-stage1" novalidate>
<label class="sr-only" for="stage1-amount">Amount in thousands</label>
<div class="input-group mb-1 mr-sm-1">
<div class="input-group-prepend"><div class="input-group-text">£</div></div>
<input type="number" step="5000" min="0" class="form-control" id="stage1-amount" required>
<div class="invalid-feedback">Please enter an amount to proceed</div>
</div>
<button type="submit" class="btn btn-secondary mb-1">Enter</button>
</div>
</form>
And this is my JavaScript:
d3.select('#form-stage1').on('submit', function(e) {
d3.event.preventDefault();
d3.event.stopPropagation();
d3.select(this).attr('class', 'was-validated');
});
Try this :
var form = document.getElementById('form-stage1');
d3.select('#form-stage1').on('submit', function(e) {
d3.event.preventDefault();
d3.event.stopPropagation();
d3.select(this).attr('class', 'form-inline was-validated');
$(".invalid-feedback").show();
if (form.checkValidity() !== false) {
d3.select('#stage1-results').style('display', 'inline-block');
var val = d3.select('#stage1-amount').property("value");
d3.select('#stage1-output').text(formatPounds(val));
var percentile = getPercentile('property', val)
d3.select('#stage1-lower').text(percentile);
d3.select('#stage1-higher').text(100-percentile-1);
}
});
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
.form-control{
width:auto!important;
flex:0!important;
}
.input-group{
width:auto!important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container">
<form class="form-inline needs-validation" id="form-stage1" novalidate>
<label class="sr-only" for="stage1-amount">Amount in thousands</label>
<div class="input-group mb-1 mr-sm-1">
<div class="input-group-prepend"><div class="input-group-text">£</div></div>
<input type="number" step="5000" min="0" class="form-control" id="stage1-amount" required>
</div>
<button type="submit" class="btn btn-secondary mb-1">Enter</button>
<div class="invalid-feedback">Please enter an amount to proceed</div>
</div>
</form>
</div>
https://jsfiddle.net/aq9Laaew/215767/

How to display the title in the center?

This is the output of my code:
I want the "welcome to the site" to be displayed at center of the page, how do i do this?
This is the code of app.component.html here I haved {{title}} templated which will be displayed at the top of the page.
<h4>{{title}}</h4>
<div class="col-sm-10">
<button type="button" class="btn btn-default" (click)="createEmp()">Create Employee</button>
</div>
<div style="margin-top: 60px;">
<div class = "container">
<div *ngIf="add">
<h2>Add Employee:</h2>
<form class="form-horizontal" #empForm="ngForm">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" minlength="4" [(ngModel)]="model.name" placeholder="Enter Your Name" #name="ngModel" required/>
<div *ngIf="name.invalid && (name.dirty || name.touched)" class="alert alert-danger">
<div *ngIf="name.errors.required">
Name is required.
</div>
<div *ngIf="name.errors.minlength">
Name must be at least 4 characters long.
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="position">Position:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="position" [(ngModel)]="model.position" placeholder="Enter your position" required />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="salary">Salary:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="salary" [(ngModel)]="model.salary" placeholder="Enter Salary" required />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default" (click)="addEmployee()" [disabled]="empForm.invalid">Add Employee</button>
</div>
</div>
</form>
</div>
<div *ngIf="edit">
<h2>Update Employee:</h2>
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name"
name="name" [(ngModel)]="model2.name" placeholder="Enter Your Name" #name="ngModel" required/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="position">Position:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="position" name="position" [(ngModel)]="model2.position" placeholder="Enter your position" required/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="salary">Salary:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="salary" name="salary" [(ngModel)]="model2.salary" placeholder="Enter Salary" required/>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default" (click)="updateEmployee()">update Employee</button>
</div>
</div>
</form>
</div>
<div *ngIf="Show">
<h2>Employee Details</h2>
<table class="table table-bordered">
<thead>
<tr>
<th width=400>Name</th>
<th width=400>Position</th>
<th width=200>Salary</th>
<th width=400>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let employee of employees; let i=index">
<td>{{employee.name}}</td>
<td>{{employee.position}}</td>
<td>{{employee.salary}}</td>
<td>
<a class="btn btn-success" (click)="editEmployee(i)">Edit</a>
<a class="btn btn-danger" (click)="deleteEmployee(i)">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
this is the ts file where i added title name here
import {Component, OnInit} from '#angular/core';
import { FormControl, FormGroup , Validators} from '#angular/forms';
import { FormsModule, ReactiveFormsModule } from '#angular/forms';
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
model:any={};
model2:any={};
edit= false;
add=false;
create=true;
Show=false;
myValue;
ngOnInit(){
this.model = new FormGroup({
'name': new FormControl(this.model.name, [
Validators.required,
Validators.minLength(4),
]),
'position': new FormControl(this.model.position),
'salary': new FormControl(this.model.salary, Validators.required)
});
}
title = 'Welcome to the Site';
employees = [{name :"Sunil", position : "Developer", salary : 20000},
{name :"Vamshi", position : "Java Developer", salary : 30000},
{name : "Chethan", position : ".Net Developer", salary : 10000}];
createEmp(){
this.add=true;
this.create=false;
this.Show=false;
this.edit=false;
}
addEmployee()
{
console.log()
this.employees.push(this.model);
this.Show = true;
this.add=false;
this.model = {};
}
deleteEmployee(i){
this.employees.splice(i,1)
this.Show=true;
console.log(i);
}
editEmployee(k){
this.edit = true;
this.Show=false;
this.add=false;
this.model2.name = this.employees[k].name;
this.model2.position = this.employees[k].position;
this.model2.salary = this.employees[k].salary;
this.myValue = k;
}
updateEmployee(){
this.Show=true;
this.edit = false;
let k = this.myValue;
for(let i=0;i<this.employees.length;i++){
if(i==k)
{
this.employees[i]= this.model2;
this.model2 = {};
}
}
}
}
The title must be displayed center at all of the pages tag is not helping for me. Is there another way to do this?
You just need to use the align:center; css for your <h4> tag that has the title value:
h4 {
text-align: center;
}

nested component in angular are not trigger for id

i am trying nested component in angular 2 where we add dynamically component on click multiple time but the problem is when we click on check box of second component it always trigger the first component checkbox..my code in html is follow how to solve the issue the other controls are work fine...
<div [formGroup]="itemForm" class="row order-persons-row">
<div class="small-12 columns">
<div class="order-item">
<div class="row order-persons-row align-stretch">
<div class="small-12 medium-6 columns">
<div class="order-item-col-top">
<div>Diagnosis (ICD10) *</div>
<div>
<select formControlName="icd9" name="icd9">
<option value="">Select Diagnosis</option>
<option value="husker">Husker</option>
<option value="starbuck">Starbuck</option>
<option value="hotdog">Hot Dog</option>
<option value="apollo">Apollo</option>
</select>
<control-messages [control]="itemForm.controls.icd9" [name]="'Diagnosis'"></control-messages>
</div>
<div class="order-item-sep"></div>
<div>Item-HCPC *</div>
<div>
<select formControlName="hcpcs" name="hcpcs">
<option value="">Select Item-Hcpc</option>
<option value="husker">Husker</option>
<option value="starbuck">Starbuck</option>
<option value="hotdog">Hot Dog</option>
<option value="apollo">Apollo</option>
</select>
<control-messages [control]="itemForm.controls.hcpcs" [name]="'Hcpc'"></control-messages>
</div>
</div>
</div>
<div class="small-12 medium-6 columns">
<div class="order-item-col-top">
<div>Justification</div>
<div><input type="text" formControlName="justification" name="justification" class="" placeholder="Justification"/></div>
<control-messages [control]="itemForm.controls.justification" [name]="'justification'"></control-messages>
<div class="order-item-sep"></div>
<div class="flex-container align-justify"><span>Quantity *</span></div>
<div class="flex-container align-justify"><input type="number" formControlName="quantityFrequence" class="" placeholder="Quantity"/></div>
<control-messages [control]="itemForm.controls.quantityFrequence" [name]="'Quantity'"></control-messages>
</div>
</div>
</div>
<div class="row order-persons-row align-stretch">
<div class="small-12 medium-6 columns">
<div class="order-item-col-bottom order-docs">
<div class="order-item-sep"></div>
<div class="flex-container align-justify">
<span>Prior authorization required?</span>
<span><div class="switch tiny">
<input class="switch-input" id="priorAuthRequired" formControlName="priorAuthRequired" type="checkbox" name="priorAuthRequired" checked>
<label class="switch-paddle" for="priorAuthRequired">
<span class="show-for-sr">Tiny Sandwiches Enabled</span>
</label>
</div>
</span>
</div>
<div class="flex-container align-justify">
<span>Beyond quantity limit?</span>
<span><div class="switch tiny">
<input class="switch-input" formControlName="beyondQtyLimit" id="beyondQtyLimit[]" type="checkbox" name="beyondQtyLimitName">
<label class="switch-paddle" for="beyondQtyLimit[]">
<span class="show-for-sr">Tiny Sandwiches Enabled</span>
</label>
</div>
</span>
<control-messages [control]="itemForm.controls.beyondQtyLimit" [name]="'Quantity'"></control-messages>
</div>
<div class="flex-container align-justify">
<div class="form-warning is-visible">
Additional documentation must be provided to support determination of medical necessity.
</div>
</div>
<div class="flex-container align-justify">
<span>Custom item?</span>
<span><div class="switch tiny">
<input class="switch-input" formControlName="customItem" id="customItem" type="checkbox" name="customItemName">
<label class="switch-paddle" for="customItem">
<span class="show-for-sr">Tiny Sandwiches Enabled</span>
</label>
</div>
</span>
</div>
<div class="flex-container align-justify">
<div class="form-warning is-visible">
Additional documentation must be provided to support determination of medical necessity.
</div>
</div>
</div>
</div>
<div class="small-12 medium-6 columns">
<div class="order-item-col-bottom order-docs">
<div class="order-item-sep"></div>
<div>Attachments<span class="button-span"><button type="button" class="button order-doc-button">Add New</button></span></div>
<ul>
<li class="order-doc"> DocumentName.pdf <span class="button-span"><button type="button" class="button order-doc-button">View</button></span><span class="button-span"><button type="button" class="button order-doc-button">Remove</button></span></li>
<li class="order-doc"> Document2222Name.pdf <span class="button-span"><button type="button" class="button order-doc-button">View</button></span><span class="button-span"><button type="button" class="button order-doc-button">Remove</button></span></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
here is component
#Component({
moduleId: module.id,
selector: 'Orders-order',
templateUrl: 'order.component.html',
styleUrls: ['order.component.css']
})
export class OrderComponent implements OnInit {
id: any;
subscription: any;
selectedVendor: Vendor;
order: Order;
managerList:any;
mylist:any;
item:number;
orderForm: FormGroup;
customDetails:FormGroup;
isCCP:boolean=true;
isXIX:boolean=false;
toDay:string;
nextDay:string;
nextDate:string;
initial:boolean=true;
revision:boolean=true;
recertification:boolean=true;
init:any;
constructor(private errorService: ErrorService,
private router: Router, private _route: ActivatedRoute,
private fb: FormBuilder, private orderService: OrderService) {
}
ngOnInit() {
this.typeXIX();
}
initItem1() {
return this.fb.group({
hcpcs: ['', Validators.required],
quantityFrequence: ['',Validators.required],
icd9:['',Validators.required],
justification:['',],
beyondQtyLimit:['',],
customItem:['',],
priorAuthRequired:['',]
});
}
typeXIX(){
this.isCCP=false;
this.isXIX=true;
if(this.isXIX) {
this.orderForm = this.fb.group({
entity: [''],
coordinator: this.fb.group({
id: ['', Validators.required]
}),
patient: this.fb.group({
id: ['', Validators.required]
}),
hsp: this.fb.group({
id: ['', Validators.required]
}),
vendor: this.fb.group({
id: ['', Validators.required]
}),
providerGroup:this.fb.group({
id:['',Validators.required]
}),
customDetails: this.fb.group({
extraInformation: ['',],
lines: this.fb.array([
this.initItem1(),
]),
durationNeed: ['',],
durationSupply: ['',],
lastSeenPhysician: ['', Validators.required]
}),
});
}
}
addItemXIX() {
const control = <FormArray>this.orderForm.controls['customDetails'].get('lines');
control.push(this.initItem1());
}
removeItemXIX(i: number) {
const control = <FormArray>this.orderForm.controls['customDetails'].get('lines');
control.removeAt(i);
}
}

How can I fix the position of a second colum?

I have two colums with textfield. You can choose the amount of the textfields with the combobox. Here is the first picture
When I choose the amount of textfields from the right side then you can this situation.
So far so good but when I choose 0 on the left side the second colums comes to the left side.
When I choose 0 I want that the right colum stay in his place instead of going to the left. How can I do that?
The code:
<div class="form-group">
<label>Invulveld 1:</label>
<input ng-hide="vm.datasource.billLevel < 1 " type="text" ng-model="vm.datasource.text1Bill" style="width:148px;" />
<input ng-hide="vm.datasource.contractLevel < 1" type="text" ng-model="vm.datasource.text1Contract" style="margin-right:153px; width:156px;" />
</div>
<div class="form-group">
<label>Invulveld 2:</label>
<input ng-hide="vm.datasource.billLevel < 2" type="text" ng-model="vm.datasource.text2Bill" style="width:148px;" />
<input ng-hide="vm.datasource.contractLevel < 2" type="text" ng-model="vm.datasource.text2Contract" style="margin-right:153px; width:156px;" />
</div>
<div class="form-group">
<label>Invulveld 3:</label>
<input ng-hide="vm.datasource.billLevel < 3" type="text" ng-model="vm.datasource.text3Bill" style="width:148px;" />
<input ng-hide="vm.datasource.contractLevel < 3" type="text" ng-model="vm.datasource.text3Contract" style="margin-right:153px; width:156px;" />
</div>
<div class="form-group">
<label>Invulveld 4:</label>
<input ng-hide="vm.datasource.billLevel < 4" type="text" ng-model="vm.datasource.text4Bill" style="width:148px;" />
<input ng-hide="vm.datasource.contractLevel < 4" type="text" ng-model="vm.datasource.text4Contract" style="margin-right:153px; width:156px;" />
</div>
<div class="form-group">
<label>Invulveld 5:</label>
<input ng-hide="vm.datasource.billLevel < 5" type="text" ng-model="vm.datasource.text5Bill" style="width:148px;" />
<input ng-hide="vm.datasource.contractLevel < 5" type="text" ng-model="vm.datasource.text5Contract" style="margin-right:153px; width:156px;" />
</div>
There are many ways to achieve what you want,
It must include either float, fix width.
Here is a solution which includes repeater which is very recommended
Html:
<div class="wrapper" ng-app="myApp" ng-controller="Ctrl">
<div class="left">
<select ng-model="vm.selectLeft">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
<div>
<input ng-repeat="txt in getText('left',vm.selectLeft) track by $index" ng-value="txt" />
</div>
</div>
<div class="right">
<select ng-model="vm.selectRight">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
<div>
<input ng-repeat="txt in getText('right',vm.selectRight) track by $index" ng-value="txt"/>
</div>
</div>
</div>
CSS:
.wrapper{
width: 400px;
}
.left,
.right{
float:left;
width: 40%;
margin:10px;
}
select, input{
width:100%;
}
.wrapper input {
margin-top: 10px;
}
JS:
var app = angular.module('myApp', []);
app.controller('Ctrl', ['$scope', function($scope) {
$scope.getText = function(txt, length) {
var newArr = [];
for (var i = 0; i < length; i++) {
newArr.push(txt + i);
}
return newArr;
}
}]);
Fiddle example

Resources