I've encountered various solutions to this issue, but when I integrate an Angular2 component inside the divs, it fails to function properly.
Here is my progress so far: https://i.stack.imgur.com/qJ8a9.jpg
Code:
<div id="container">
<div id="categoriesContainer">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
</div>
<div id="products-container">
<product-details *ngFor="let product of products$ | async" id="prodcut"
[product]="product"
[canAddProductToCart]="canAddToCart(product.$key) | async"
(onAddToCart)="addToCart($event)"></product-details>
<button md-button
*ngIf="!showCreateProductComponent"
id="create-product-button"
[disabled]="disableCreateProductButton$ |async"
(click)="showCreateProductComponent=true">
<i class="material-icons">add</i>
</button>
<create-product id="create-product"
(onCencel)="showCreateProductComponent=false"
(onCreateProduct)="onCreateProduct($event)"
*ngIf="showCreateProductComponent"></create-product>
</div>
<div style="clear: both"></div>
</div>
css:
//splitting the div into 2 columns
#container
{
border-style: solid;
border-width: 1px;
border-color: green;
padding: 10px;
margin: 10px
}
#categoriesContainer
{
width: 15%;
border-style: solid;
border-width: 1px;
border-color: blue;
float: left;
}
#products-container
{
border-style: solid;
border-width: 1px;
width: 85%;
border-color: red;
}
//styling for angular2 components
#prodcut
{
float: left;
margin-right: 10px;
margin-bottom: 10px;
}
#create-product
{
float: left;
margin-right: 10px;
margin-bottom: 10px;
}
#create-product-button
{
float: left;
margin-right: 10px;
margin-bottom: 10px;
}
My Desired Layout: (the cards will only be in the red square.)
https://i.stack.imgur.com/mI7Mn.jpg
Questions:
- How can I resolve this issue and why does it work fine when I replace the Angular2 components with simple HTML text?
Can I simplify this code without impacting anything:
<div id="categoriesContainer" style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left"> <categories (onCategoryChanged)="categoryChanged($event)"></categories>
To:
<categories id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left"
(onCategoryChanged)="categoryChanged($event)"></categories>
Thank you!