I am using ionic 2.
I need to get HTML element value.
Actually, I used viewchild.
Here is my html template code
<div class="messagesholder" *ngFor="let chat of chatval | orderby:'[date]'; let last = last">
       {{last ? callFunction() : ''}} 
   <div *ngIf="chat.sender == currentuser || chat.receiver == currentuser">    
     <p class="chat-date"  id="abc" #abc>{{chat.date | amDateFormat:'LL'}}</p>                 
              {{checkdate()}}                         
   </div>
chat.date value is firebase value. I access this element. But I didn't get the value of the element.
Here is my component
import {Component, ElementRef,ViewChild, OnInit} from '@angular/core';
    export class ChatPage   {
      @ViewChild(Content) content: Content;
      @ViewChild('abc')abc: ElementRef;
       constructor(){}
      ngAfterViewInit(){
       console.log("afterinit");
       console.log(this.abc.nativeElement.value);
      }
    }
I referred this link How can I select an element in a component template?
I tried in many ways.
But I am getting this error
Cannot read property 'nativeElement' of undefined.
 
     
     
     
     
     
     
     
     
     
     
    
` inside an `*ngIf`? Can you reproduce in Plunker? From what your question shows it should just work. What is `value` supposed to return? The `
` element doesn't have a `value` property.
– Günter Zöchbauer Apr 13 '17 at 04:39does not have *ngIf. and i console the value of this.abc its have on innerhtml etc....But Same time i consoled this.abc.nativeelement. I cannot access
– ANISUNDAR Apr 13 '17 at 05:12