How To

Customize the card image title position

Card Image titles are placed as always Bottom-Left Corner only, You can manually customize to placing titles anywhere over the image by adding styles.

Source
Preview
app.component.ts
app.module.ts
main.ts
index.css
import { Component, ViewChild } from '@angular/core';
import { DropDownList } from '@syncfusion/ej2-dropdowns';

@Component({
    selector: 'app-container',
    template: `
            <div>
            <div class="e-card">
                <div class="e-card-image">
                    <div class="e-card-title">Node.js</div>
                </div>
                <div class="e-card-content">
                    Node.js is a wildly popular platform for writing web applications that has revolutionized web development in many ways, enjoying
                    support across the open source community as well as industry.
                </div>
        </div>
    </div>
    <div style="Margin: 5px 0;width:300px">
        <select id="title_position">
            <option value="bottom-left">BottomLeft</option>
            <option value="top-left">TopLeft</option>
            <option value="top-right">TopRight</option>
            <option value="bottom-right">BottomRight</option>
        </select>
    </div>        `
})

export class AppComponent {
    @ViewChild('element') element;

ngAfterViewInit () {
// initialize DropDownList component
let dropDownListObject: DropDownList = new DropDownList({
    placeholder:"Select Position",
    change: changed,
});

// render initialized DropDownList
dropDownListObject.appendTo('#title_position');
}
function changed(e) {
    let cardEle = document.querySelector('.e-card');
    let titleEle = cardEle.querySelector('.e-card-image .e-card-title');
    titleEle.className = ''
    titleEle.classList.add('e-card-title');
    titleEle.classList.add('e-card-'+e.value);
}

}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
    ],
    declarations: [AppComponent,],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
#container {
    visibility: hidden;
}

#loader {
    color: #008cff;
    height: 40px;
    left: 45%;
    position: absolute;
    top: 45%;
    width: 30%;
}

.e-card-image {
    background: url('./sample.jpg');
    height: 164px;
}

.e-card {
    width: 200px;
    margin: auto;
}

.topleft {
    top: 0;
    bottom: auto !important;
}

.topright {
    top: 0;
    text-align: right;
    bottom: auto !important;
}

.bottomright {
    bottom: 0;
    right: 0;
    text-align: right;
}

Integrate other component inside the card

You can integrate any component inside the card element. Here ListView component is placed inside the card for showcasing the To-Do list.

Source
Preview
app.component.ts
app.module.ts
main.ts
index.css
import { Component, ViewChild } from '@angular/core';
import { ListView } from '@syncfusion/ej2-lists';

@Component({
    selector: 'app-container',
    template: `
        <div style="margin: 50px;">
            <!--element which is going to render the Card-->
            <div tabindex="0" class="e-card" id="basic">
                <div class="e-card-title">To-Do List</div>
                <div class="e-card-separator"></div>
                <div class="e-card-content">
                    <div id='element'></div>
                </div>
            </div>
        </div>       `
})

export class AppComponent {
    @ViewChild('element') element;

ngAfterViewInit () {
//define the array of JSON
let todoList: { [key: string]: Object }[] = [
    {  todoList: 'Pay Bills' },
    {  todoList: 'Call Chris' },
    {  todoList: 'Meet Andrew' },
    {  todoList: 'Visit Manager' },
    {  todoList: 'Customer Meeting' },
];

//Initialize ListView component
let listviewInstance: ListView = new ListView({
    dataSource: todoList,
    //map the appropriate columns to fields property
    fields: { text: 'todoList' },
    showCheckBox: true,
});

//Render initialized ListView
listviewInstance.appendTo("#element");
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
    ],
    declarations: [AppComponent,],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
#container {
    visibility: hidden;
}

#loader {
    color: #008cff;
    height: 40px;
    left: 45%;
    position: absolute;
    top: 45%;
    width: 30%;
}