Angular 5 Sample 1

First Angular 5 sample code in VS Code. This code sample will maintain an array of object customers locally and search button will demonstrate how we can attach an event and how to use a stractureal directive (*ngFor) in angular. I have created a component called detail.
The cod ein detail.component.ts:

 import { Component, OnInit } from '@angular/core';
  selector: 'app-detail',
  templateUrl: './detail.component.html',
  styleUrls: ['./detail.component.css']
export class DetailComponent implements OnInit {
  customers: any[];
  public LoadCustomers(filterText: string): void {
    this.customers = [
      { id: 1, Name: 'Tom Paul' },
      { id: 2, Name: 'John Doe' },
      { id: 3, Name: 'Jijo Venginikkadan' },
      { id: 4, Name: 'Alex George' },

    if (filterText !== '') {
      const filteCustomerList: any[] = [];
      this.customers.forEach(cust => {
        if (cust.Name.toLowerCase().includes(filterText.toLowerCase())) {
      this.customers = filteCustomerList;
  constructor() { }

  ngOnInit() {
  OnCustomerSearch(searchTerm: string): void {


Template detail.component.html would looks like:

<div class="form-group">
  <div class="md-col-4">
    Enter Student Name:
  <div class="md-col-4">


<table class="table table-responsive table-bordered table-striped">
      <th>Customer ID</th>
      <td>{{s.Name | uppercase}}</td>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s