Loop 2d array in same html tag on thymleaf - thymeleaf

I have this html to render in thymleaf:
<div id="puzzle">
<div number="1" class="cell-puzzle row-1 col-1">1</div>
<div number="2" class="cell-puzzle row-1 col-2">2</div>
<div number="3" class="cell-puzzle row-1 col-3">3</div>
<div number="4" class="cell-puzzle row-1 col-4">4</div>
<div number="5" class="cell-puzzle row-2 col-1">5</div>
<div number="6" class="cell-puzzle row-2 col-2">6</div>
<div number="7" class="cell-puzzle row-2 col-3">7</div>
<div number="8" class="cell-puzzle row-2 col-4">8</div>
<div number="9" class="cell-puzzle row-3 col-1">9</div>
<div number="10" class="cell-puzzle row-3 col-2">10</div>
<div number="11" class="cell-puzzle row-3 col-3">11</div>
<div number="12" class="cell-puzzle row-3 col-4">12</div>
<div number="13" class="cell-puzzle row-4 col-1">13</div>
<div number="14" class="cell-puzzle row-4 col-2">14</div>
<div number="15" class="cell-puzzle row-4 col-3">15</div>
<div number="0" class="cell-puzzle row-4 col-4 cell-puzzle-zero"></div>
</div>
here is implementation on thymleaf:
<div id="puzzle">
<span th:each="row,iter : *{matrix}" >
<div th:each="col, iter2: ${row}" th:attr="number=${iter.index + 1}" th:class="'cell-puzzle row-' + ${iter.index + 1} + ' col-' + ${iter2.index + 1}" th:text="${col}"></div>
</span>
<div number="0" class="cell-puzzle row-4 col-4 cell-puzzle-zero"></div>
</div>
i need to wrap div inside span to have two th:each
output html will be different with original.
When i try to merge two th:each into same div then it throw
error:
<div id="puzzle">
<div th:each="row,iter : *{matrix}" th:each="col, iter2: ${row}" th:attr="number=${iter.index + 1}" th:class="'cell-puzzle row-' + ${iter.index + 1} + ' col-' + ${iter2.index + 1}" th:text="${col}"></div>
<div number="0" class="cell-puzzle row-4 col-4 cell-puzzle-zero"></div>
</div>
error:
org.attoparser.ParseException: (Line = 31, Column = 74) Malformed markup: Attribute "th:each" appears more than once in element
I know the alternative way of this one is translate 2d array into 1d array, but then we need to calculate index manually. so please skip this way \
Does anyone know how to use only thymleaf on this case?

Use a <th:block /> instead of the <span />. You can put a th:each in it, and it won't output anything.
<div id="puzzle">
<th:block th:each="row,iter : *{matrix}">
<div th:each="col, iter2: ${row}" th:attr="number=${iter.index + 1}" th:class="'cell-puzzle row-' + ${iter.index + 1} + ' col-' + ${iter2.index + 1}" th:text="${col}"></div>
</th:block>
<div number="0" class="cell-puzzle row-4 col-4 cell-puzzle-zero"></div>
</div>

Related

Using boostrap grid with angular material mat-list

I'm trying to use bootstrap 5 grid with angular material component mat-list but it's not working.
I want the text of the 2 field to use 12 columns on small device.
I have made a test using div and I get the right result but when I try to use boostrap container/row and col-X class with the mat-list it's not working.
Using div
<div *ngIf="dto">
<div class="container" >
<div class="row pb-2" >
<span class="champ col-12 col-md-6">NOM D'USAGER</span>
<span class="donnee col-12 col-md-6">example 1</span>
</div>
<mat-divider></mat-divider>
<div class="row pb-2" >
<span class="champ col-12 col-md-6">COURRIEL</span>
<span class="donnee col-12 col-md-6">example 2</span>
</div>
<mat-divider></mat-divider>
</div>
</div>
With angular material mat-list
<mat-list role="list" class="container" *ngIf="dto">
<mat-list-item role="listitem" class="row pb-2">
<span class="champ col-12 col-md-6">NOM D'USAGER</span>
<span class="donnee col-12 col-md-6">example 1</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item role="listitem" class="row pb-2" >
<span class="champ col-12 col-md-6">COURRIEL</span>
<span class="donnee col-12 col-md-6">example 2</span>
</mat-list-item>
<mat-divider></mat-divider>
</mat-list>
Edit:
I added a demo code in stackblitz
stackblitz
When material renders the elements for mat list, an additional div element gets added between mat-list-item and the content, the rendered structure looks like this
<mat-list-item class="mat-list-item" role="listitem" class="row pb-2 w-100">
<div class="mat-list-item-content">
<span class="champ col-12 col-md-6">NOM D'USAGER</span>
<span class="donnee col-12 col-md-6">example 1</span>
</div>
</mat-list-item>
The col elements are not the direct child of the row element, which is why the flex properties do not work
To fix this wrap the spans with a div with a class row
<mat-list role="list" class="container-fluid">
<mat-list-item role="listitem">
<div class="row pb-2 w-100">
<span class="champ col-12 col-md-6">NOM D'USAGER</span>
<span class="donnee col-12 col-md-6">example 1</span>
</div>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item role="listitem">
<div class="row pb-2 w-100">
<span class="champ col-12 col-md-6">COURRIEL</span>
<span class="donnee col-12 col-md-6">example 2</span>
</div>
</mat-list-item>
<mat-divider></mat-divider>
</mat-list>

Bootstrap gutter class gx-5 isn't working horizontally

I want some gaps between my cards horizontally. But when I am adding gx-5 bootstrap 5 class, it's not taking any gap horizontally. here is my code below.
<div className="container">
<div className="row gx-5">
{myProducts.map((product) => (
<div
key={product._id}
class="card col-sm-12 col-md-4 "
style={{ boxShadow: "rgba(0, 0, 0, 0.24) 0px 3px 8px" }}
>
<img class="card-img-top img-fluid" src={product.image} alt="" />
<div class="card-body">
<h5 class="card-title">{product.name}</h5>
<p class="card-text">{product.description}</p>
</div>
</div>
))}
</div>
</div>
Is anyone there to help me, please?
Try this card snippet out:
<div class="col-sm-12 col-md-4">
<div class="card">
<img class="card-img-top" src="..." alt="..." />
<div class="card-body">
<h5 class="card-title">Product</h5>
<p class="card-text">Product</p>
</div>
</div>
</div>
Explanation:
I just nested a new card div inside the column because card class affects how Boostrap manages the gutters.
A working example:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row gx-5">
<div class="col-sm-12 col-md-4">
<div class="card">
<img class="card-img-top" src="https://media.istockphoto.com/photos/forest-wooden-table-background-summer-sunny-meadow-with-green-grass-picture-id1353553203?b=1&k=20&m=1353553203&s=170667a&w=0&h=QTyTGI9tWQluIlkmwW0s7Q4z7R_IT8egpzzHjW3cSas=" alt="" />
<div class="card-body">
<h5 class="card-title">Product 01</h5>
<p class="card-text">Product 01 description</p>
</div>
</div>
</div>
<div class="col-sm-12 col-md-4">
<div class="card">
<img class="card-img-top" src="https://media.istockphoto.com/photos/forest-wooden-table-background-summer-sunny-meadow-with-green-grass-picture-id1353553203?b=1&k=20&m=1353553203&s=170667a&w=0&h=QTyTGI9tWQluIlkmwW0s7Q4z7R_IT8egpzzHjW3cSas=" alt="" />
<div class="card-body">
<h5 class="card-title">Product 01</h5>
<p class="card-text">Product 01 description</p>
</div>
</div>
</div>
<div class="col-sm-12 col-md-4">
<div class="card">
<img class="card-img-top" src="https://media.istockphoto.com/photos/forest-wooden-table-background-summer-sunny-meadow-with-green-grass-picture-id1353553203?b=1&k=20&m=1353553203&s=170667a&w=0&h=QTyTGI9tWQluIlkmwW0s7Q4z7R_IT8egpzzHjW3cSas=" alt="" />
<div class="card-body">
<h5 class="card-title">Product 01</h5>
<p class="card-text">Product 01 description</p>
</div>
</div>
</div>
</div>
</div>
Note: I converted the code snippet into plain HTML please consider converting it back to its original state without changing the classes.

Create a div for each parent?

I need to wrap all the childrens of the parent with a div. In the example below I managed to put a div tag after each parent but how do I put an end /div tag at the end of the chidrens.
I tried with document.createElement, and now with insertAdjacentHTML ..., what is the best way to fix this, or the best way to encode it?
var divs = document.getElementById("container").querySelectorAll('.activ-window *');
var elements = "";
divs.forEach(function(elem){
if (elem.firstChild) {
elements += elem.insertAdjacentHTML("afterbegin", '<div id="afterParent" style="display:block;">');
elem.insertAdjacentHTML("afterend", '</div>');
}
});
document.getElementById("demo").innerHTML = elements;
<div id="container" class="activ-window">
<div id="parent1">
<div id="child" ></div>
<div id="child" ></div>
</div>
<div id="parent2">
<div id="child" ></div>
<div id="paren3" >
<div id="child" ></div>
<div id="child" ></div>
<div id="child" ></div>
</div>
</div>
</div>
It should look like:
<div id="container" class="activ-window">
<div id="parent1">
<div id="afterParent" style="display:block;">
<div id="child" ></div>
<div id="child" ></div>
</div>
</div>
<div id="parent2">
<div id="afterParent" style="display:block;">
<div id="child" ></div>
</div>
<div id="paren3" >
<div id="afterParent" style="display:block;">
<div id="child" ></div>
<div id="child" ></div>
<div id="child" ></div>
</div>
</div>
</div>
</div>
Edit for Nick:
This is with text(see Parent1):
<div id="parent1">Parent1
<div id="child" >child1</div>
<div id="child" >child1</div>
</div>
I get it with your code
<div id="parent1">
<div id="afterParent" style="display:block;">
"Parent1"
<div id="child" >Child1</div>
<div id="child" >Child1</div>
</div>
</div>
It should look:
<div id="parent1">Parent1
<div id="afterParent" style="display:block;">
<div id="child" >Child1</div>
<div id="child" >Child1</div>
</div>
</div>
If you want to enclose all the divs beneath each parent in a new div, you can create a new div element, move all the non-text children to it, and then add that div as a child to the original parent:
const container = document.getElementById("container");
const parentDivs = container.querySelectorAll('.activ-window div[id^="parent"]');
for (let parent of parentDivs) {
// create a new div
let after = document.createElement('div');
after.id = 'after' + parent.id;
after.style.display = 'block';
// move the parent's non-text children to it
let children = parent.childNodes;
for (let i = 0; i < children.length; i++) {
if (children[i].nodeType != Node.TEXT_NODE) {
after.append(children[i]);
}
}
// and append it to the parent
parent.appendChild(after);
}
console.log(container.innerHTML);
<div id="container" class="activ-window">
<div id="parent1">
Parent1
<div id="child1"></div>
<div id="child2"></div>
</div>
<div id="parent2">
Parent2
<div id="child3"></div>
<div id="parent3">
<div id="child4"></div>
<div id="child5"></div>
<div id="child6"></div>
</div>
</div>
</div>

Ionic 4: Side menu (ion-menu) does not close properly in IOS

I am developing an application with IONIC 4 for android and IOS.
I add a side menu (ion-menu), it works perfectly on android.
But in IOS it is giving me problems, the menu opens perfectly. But when I want to close the menu. Graphically the menu closes, but when I try to interact with the application, only the options within the side menu are activated.
Only the side menu items are useful, the rest of the application is canceled.
This is the process.
Main page normally:
I open the side menu:
I close the menu:
All this options gets blocked:
But this options still are activated, even though the menu has been hidden.
This only happen in IOS, my specifications:
My code:
<ion-menu side="start" content-id="main-content">
<ion-header class="headermenu">
<div class="spacioemenuleft">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:center;">
<img alt="logo" style="width:18.9vw; height:10.6vh; border-radius: 50%;" src="{{pictureusuariomenu}}" >
</div> </div> </div>
</div>
<div class="spacioemenuright">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div class="textsaldo2" [innerHTML]="fullname"></div>
<div class="bloque">
<div style="float:left; width:70%; height:100%" class="textsaldo2">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:center;">
PIN: {{pinusuario}}
</div> </div> </div>
</div>
<div style="float:right; width:30%; height:100%; background-color:white;" (click)="copyText()">
<img alt="logo" style="width:100%; height:100%" src="assets/imgs/compartir-b.png" >
</div>
</div>
<span class="error ion-padding" style="color:white; font-weight:bold; margin-top:1em; padding-top:0em;" *ngIf="registrado">
PIN COPIADO!!!
</span>
</div>
</div>
</div>
</ion-header>
<ion-content >
<div class="ion-padding">
<div class="espacio2 margenboton" routerLink="/recargarsaldo">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:center;">
Recargar Saldo
</div> </div> </div>
</div>
<ion-list>
<ion-item>
<div style="float:left; width:20%; height:100%; padding:0.8em;" routerLink="/profile">
<img alt="logo" style="width:2.7vh; height:2.7vh;" src="assets/imgs/perfil.png" >
</div>
<div style="float:left; width:80%; height:100%;" class="textblue2" routerLink="/profile">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:left;">
Mi perfil
</div> </div> </div>
</div>
</ion-item>
<ion-item>
<div style="float:left; width:20%; height:100%; padding:0.8em;" routerLink="/notificaciones">
<img alt="logo" style="width:2.7vh; height:2.7vh;" src="assets/imgs/11notificaciones.png" >
</div>
<div style="float:left; width:80%; height:100%;" class="textblue2" routerLink="/notificaciones">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:left;">
Notificaciones
</div> </div> </div>
</div>
</ion-item>
<ion-item>
<div style="float:left; width:20%; height:100%;padding:0.8em;" routerLink="/misretiros" >
<img alt="logo" style="width:2.7vh; height:2.7vh;" src="assets/imgs/6dolares.png" >
</div>
<div style="float:left; width:80%; height:100%;" class="textblue2" routerLink="/misretiros">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:left;">
Mis retiros
</div> </div> </div>
</div>
</ion-item>
<ion-item>
<div style="float:left; width:20%; height:100%; padding:0.8em;" routerLink="/historial">
<img alt="logo" style="width:2.7vh; height:2.7vh;" src="assets/imgs/11historial.png" >
</div>
<div style="float:left; width:80%; height:100%;" class="textblue2" routerLink="/historial">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:left;">
Historial
</div> </div> </div>
</div>
</ion-item>
<ion-item>
<div style="float:left; width:20%; height:100%; padding:0.8em;" routerLink="/contacto">
<img alt="logo" style="width:2.7vh; height:2.7vh;" src="assets/imgs/contact5.png" >
</div>
<div style="float:left; width:80%; height:100%;" class="textblue2" routerLink="/contacto">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:left;">
Contáctanos
</div> </div> </div>
</div>
</ion-item>
<ion-item>
<div style="float:left; width:20%; height:100%; padding:0.8em;">
<img alt="logo" style="width:2.7vh; height:2.6vh;" src="assets/imgs/7cerrar.png" >
</div>
<div style="float:left; width:80%; height:100%;" class="textblue2">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:left;" (click)="cerrarsession();" >
Cerrar sesión
</div> </div> </div>
</div>
</ion-item>
</ion-list>
</div>
<div style="height: 15vh; background-color:#F3F3F3; padding:0.2em;">
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:center;" >
<div style="float:left; width:40%; height:100%;" >
<div style="display:table;width:100%;height:100%;">
<div style="display:table-cell;vertical-align:middle;">
<div style="text-align:right;">
<p class="textblue2" style="font-weight:bold;">En alianza con:</p>
</div> </div> </div>
</div>
<div style="float:left; width:60%; height:100%; padding:0.1em; padding-top: 0.6em;" >
<img alt="logo" style="width:80%; height:auto" src="assets/imgs/Grupo517.png" >
</div>
</div> </div> </div>
</div>
</ion-content>
</ion-menu>
Any ideas?
<IonContent>
... other page components
{ authenticated ? <Menu/> : null }
</IonContent>
or what i have done in my example is not even render the router code that contains the menu when the user isn't authenticated
if (!authInfo || !authInfo.initialized) {
return (
<IonApp>
<IonLoading isOpen={true} />
</IonApp>
);
} else {
return (
<IonApp>
<>
{authInfo?.loggedIn === true ? (
<IonReactRouter>
<IonSplitPane contentId="main">
<Menu />
<IonRouterOutlet id="main">
<Route path="/page/:name" component={Page} exact />
<Route path="/tabs" component={TabRootPage} />
<Redirect from="/" to="/tabs" exact />
</IonRouterOutlet>
</IonSplitPane>
</IonReactRouter>
) : (
<IonReactRouter>
<Route
path="/create-account"
component={CreateAccountPage}
exact
/>
<Route path="/login" component={LoginPage} exact />
<Redirect from="/" to="/login" exact />
</IonReactRouter>
)}
</>
</IonApp>
);
}
See full app and source code here : https://github.com/aaronksaunders/ionic-sidemenu-tabs-auth-starter

Angular 4 Date Field set to null on clicking radio button

So I manage to solve the original problem by updating the package but here is what follows, a dark background with dark font color
Below is the codes for the view
<div *ngSwitchCase="'Basic'">
<md-card>
<md-card-content>
<h4>Basic Institution Subscription Page</h4>
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">Your School or Institution Profile</div>
<div class="panel-body">
<md-card>
<md-card-content>
<div class="row" style="padding-left:10px;padding-bottom:10px;padding-top:20px">
<div class="col-md-6">
<img md-card-md-image [src]="'data:image/jpg;base64,' + institution.Crest" class="crest_image" style="margin-bottom:5px;margin-left:10px" />
<h6>Select Institution Crest</h6>
<input #crest type="file" (change)="crestChangeListner($event)" style="margin-left:20px" />
</div>
<div class="col-md-6">
<img md-card-md-image [src]="'data:image/jpg;base64,' + institution.BackGroundPicture" class="bgpic_image" style="margin-bottom:5px;margin-left:10px" />
<h6 *ngIf="!institution.BackGroundPicture">Select Background Image</h6>
<input #bgpic type="file" (change)="bgpicChangeListner($event)" style="margin-left:20px" />
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-radio-group [(ngModel)]="institution.OwnershipCategory"
(change)="OwnershipCategorySelected($event.value)" name="ownershipCategory" class="example-margin"
[value]="institution.OwnershipCategory"
[align]="isAlignEnd ? 'end' : 'start'">
<md-radio-button class="icon-align-vertical" name="ownershipCategory" value="Public">
Public
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="ownershipCategory" value="Private">
Private
</md-radio-button>
</md-radio-group>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-select placeholder="Select Country" style="width: 100%"
id="countryID" name="countryID" class="required"
[(ngModel)]="institution.Country"
(ngModelChange)="countrySelected()">
<md-option *ngFor="let country of countries" [value]="country.CountryID">
{{ country.CountryName }}
</md-option>
</md-select>
</div>
<div class="col-md-6">
<md-select placeholder="Select Office" style="width: 100%"
id="officeID" name="officeID" class="required"
[(ngModel)]="institution.OfficeID"
(ngModelChange)="officeSelected()">
<md-option *ngFor="let office of offices" [value]="office.AdministrativeStructureID">
{{ office.AdminStructName }}
</md-option>
</md-select>
</div>
</div>
<div class="row" *ngIf="offices">
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="InstitutionID" placeholder="Enter Institution ID"
[(ngModel)]="institution.InstitutionID" required id="InstitutionID" style="width: 100%"
#InstitutionID="ngModel">
<div [hidden]="InstitutionID.valid || InstitutionID.pristine"
class="alert alert-danger">
Institution ID is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Institution Name"
[(ngModel)]="institution.InstitutionName" name="InstitutionName" id="InstitutionName" required style="width: 100%"
#InstitutionName="ngModel">
<div [hidden]="InstitutionName.valid || InstitutionName.pristine"
class="alert alert-danger">
Institution Name is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="Website" placeholder="Enter Website Address"
[(ngModel)]="institution.Website" required id="Website" style="width: 100%"
#Website="ngModel">
<div [hidden]="Website.valid || Website.pristine"
class="alert alert-danger">
Website is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Email Address"
[(ngModel)]="institution.EmailAddress" name="EmailAddress" id="EmailAddress" required style="width: 100%"
#EmailAddress="ngModel">
<div [hidden]="EmailAddress.valid || EmailAddress.pristine"
class="alert alert-danger">
Email Address is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="PostalAddress" placeholder="Enter Postal Address"
[(ngModel)]="institution.PostalAddress" required id="PostalAddress" style="width: 100%"
#PostalAddress="ngModel">
<div [hidden]="PostalAddress.valid || PostalAddress.pristine"
class="alert alert-danger">
Postal Address is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Residential Address"
[(ngModel)]="institution.ResidentialAddress" name="ResidentialAddress" id="ResidentialAddress" required style="width: 100%"
#ResidentialAddress="ngModel">
<div [hidden]="ResidentialAddress.valid || ResidentialAddress.pristine"
class="alert alert-danger">
Residential Address is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="Phone1" placeholder="Enter Phone1"
[(ngModel)]="institution.Phone1" required id="Phone #1" style="width: 100%"
#Phone1="ngModel">
<div [hidden]="Phone1.valid || Phone1.pristine"
class="alert alert-danger">
Phone1 is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Phone2"
[(ngModel)]="institution.Phone2" name="Phone2" id="Phone #2" required style="width: 100%"
#Phone2="ngModel">
<div [hidden]="Phone2.valid || Phone2.pristine"
class="alert alert-danger">
Phone2 is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md2-datepicker
style="width:100%"
class="md-input-element"
placeholder="Select Date Founded"
name="DateFounded"
(ngModel)="institution.DateFounded"
[required]="isRequired"
[disabled]="isDisabled"
[openOnFocus]="isOpenOnFocus"
[isOpen]="isOpen"
[type]="type"
[min]="minDate"
[max]="maxDate">
</md2-datepicker>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-4"><h6>Select Institution Catgory</h6></div>
<div class="col-md-8">
<md-radio-group [(ngModel)]="institution.SchoolCategory"
(change)="SchoolCategorySelected($event.value)" name="schoolCategory" class="example-margin"
[value]="institution.SchoolCategory"
[align]="isAlignEnd ? 'end' : 'start'">
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="A">
A
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="B">
B
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="C">
C
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="D">
D
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="E">
E
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="F">
F
</md-radio-button>
</md-radio-group>
</div>
</div>
</div>
</div>
</md-card-content>
</md-card>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">Shool Ownership In formation</div>
<div class="panel-body">
<md-card>
<md-card-content>
<div class="row">
<md-select placeholder="Select Owner Type" style="width: 100%"
id="ownershipTye" name="ownershipType" class="required"
[(ngModel)]="ownershipType"
(ngModelChange)="ownershipTypeSelected()">
<md-option *ngFor="let option of ownershipTypes" [value]="option">
{{ option }}
</md-option>
</md-select>
</div>
<div class="row">
<md-input-container style="width:100%">
<input mdInput name="fullName" placeholder="Enter Full Name"
[(ngModel)]="ownership.FullName" required id="fullName" style="width: 100%"
#fullName="ngModel">
<div [hidden]="fullName.valid || fullName.pristine"
class="alert alert-danger">
fullName is required
</div>
</md-input-container>
</div>
<div class="row">
<ul class="list-group">
<li class="list-group-item" *ngFor="let owner of ownerships">
<span class="badge">{{owner.FullName}}</span>
<md-checkbox name="ownerName"
(change)="fullNameSelected(owner)"
[(ngModel)]="owner.Selected">
{{owner.OwnershipTye}}
</md-checkbox>
</li>
</ul>
</div>
</md-card-content>
</md-card>
</div>
<div class="panel-footer">
<div class="row">
<div class="col-md-6">
<button md-raised-button color="primary" type="button" (click)="AddOwner()">Add Owner</button>
</div>
<div class="col-md-6">
<span class="pull-right">
<button md-raised-button color="primary" type="button" (click)="removeOwner()">Remove Owner</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</md-card-content>
</md-card>
</div>
and this part of the code for the component
isRequired = false;
isDisabled = false;
isOpenOnFocus = false;
isOpen = false;
type: string = 'date';
types: Array<any> = [
{ text: 'Date', value: 'date' },
{ text: 'Time', value: 'time' },
{ text: 'Date Time', value: 'datetime' }];
openDatepicker() {
this.isOpen = true;
setTimeout(() => {
this.isOpen = false;
}, 1000);
}
//startDate: Date = null;
setDate() {
this.institution.DateFounded = new Date();
}
minDate: Date = null;
maxDate: Date = null;
setDateRange() {
this.minDate = new Date();
this.minDate.setMonth(this.minDate.getMonth() - 3);
this.maxDate = new Date();
this.maxDate.setMonth(this.maxDate.getMonth() + 3);
}

Resources