Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49184

Search bar

$
0
0

@dipankar123 wrote:

hi guys,
facing problem related to search function
showing error when i m typing a value in search bar
ERROR TypeError: data.StudentID.toLowerCase is not a function
please help
here is my code:
html:

<ion-header>
    <ion-navbar hideBackButton>

      <ion-searchbar *ngIf="toggled" [(ngModel)]="searchstudent" [showCancelButton]="true" cancelButtonText="close" (ionCancel)="toggleSearch()"
        (ionInput)="getFilteredItem($event)"></ion-searchbar>

  </ion-navbar>
</ion-header>

and here is my .ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, MenuController } from 'ionic-angular';
import { UserTeacherProvider } from '../../providers/user-teacher/user-teacher';
import { Storage } from '@ionic/storage';


@IonicPage()
@Component({
  selector: 'page-t-student-attendence',
  templateUrl: 't-student-attendence.html',
})
export class TStudentAttendencePage {

  teacher: any;
  attendenceList: any;
  items: any;
  toggled: boolean;

  searchstudent= '';

  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public storage: Storage,
    public teacherProvider: UserTeacherProvider,
    public menuctrl: MenuController) {

    this.menuctrl.swipeEnable(true)
    this.dateWiseAttendance();
    this.toggled = false;
  }


  dateWiseAttendance() {
    console.log('subject clicked');
    this.storage.get('token').then((value) => {
      console.log('subtoken: ' + JSON.parse(value).AuthToken);
      this.teacherProvider.GetDateWiseStudentWiseAttendance(JSON.parse(value).AuthToken).then(data => {
        console.log('list: ' + data)
        this.attendenceList = data;
        this.items = data;
      });
    });
  }

  toggleSearch() {
    this.toggled = this.toggled ? false : true;
  }

  getFilteredItem(searchbar) {
    var item = searchbar.target.value;
    this.attendenceList = this.items.filter((data) => {
      //let myItem = JSON.parse(JSON.stringify(data))
      return (data.StudentID.toLowerCase().indexOf(item.trim().toLowerCase()) > -1);
    });
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TStudentAttendencePage');
  }

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>