Angular 5 - Why is my input property undefined?Angular HTML bindingAngular EXCEPTION: No provider for Http@Input property is undefined in angular 2's onInitAngular exception: Can't bind to 'ngForIn' since it isn't a known native propertyWhat is the equivalent of ngShow and ngHide in Angular 2+?Angular/RxJs When should I unsubscribe from `Subscription`How to detect when an @Input() value changes in Angular?Huge number of files generated for every Angular projectCan't bind to 'ngModel' since it isn't a known property of 'input'Error TypeError: Cannot read property 'fromDate' of undefined

How are aircraft depainted?

Make 2019 with single digits

Bit one of the Intel 8080's Flags register

How are unbalanced coaxial cables used for broadcasting TV signals without any problems?

How to stabilise the bicycle seatpost and saddle when it is all the way up?

Where to disclose a zero day vulnerability

How do EVA suits manage water excretion?

Why is the T-1000 humanoid?

Were Roman public roads build by private companies?

POSIX compatible way to get user name associated with a user ID

What is and what isn't ullage in rocket science?

How would you control supersoldiers in a late iron-age society?

What hard drive connector is this?

Telling my mother that I have anorexia without panicking her

How major are these paintwork & rust problems?

why car dealer is insisting on loan v/s cash

What's 待ってるから mean?

Which is the current decimal separator?

3d printed bricks quality?

What was the ultimate objective of The Party in 1984?

Will the UK home office know about 5 previous visa rejections in other countries?

Diffraction of a wave passing through double slits

Bash, import output from command as command

I asked for a graduate student position from a professor. He replied "welcome". What does that mean?



Angular 5 - Why is my input property undefined?


Angular HTML bindingAngular EXCEPTION: No provider for Http@Input property is undefined in angular 2's onInitAngular exception: Can't bind to 'ngForIn' since it isn't a known native propertyWhat is the equivalent of ngShow and ngHide in Angular 2+?Angular/RxJs When should I unsubscribe from `Subscription`How to detect when an @Input() value changes in Angular?Huge number of files generated for every Angular projectCan't bind to 'ngModel' since it isn't a known property of 'input'Error TypeError: Cannot read property 'fromDate' of undefined






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-3















I'm new to Angular5 and searched for hours but couldn't resolve my issue.
Every related threads on SO are not in the same version as me.



I have an input on which I want to trigger a function when something is typed in that input.



Here's my input:



<input
#autocompleteInput
class="inputHeader"
(click)="openSearch()"
placeholder="Coupe homme, lissage brésilen, ..."
/>


Here's my input property declaration:



@Input() autocompleteInput: string;


When I console.log(this.autocompleteInput); in the ngOnInit() method, it display "undefined".



What am I doing wrong ?



Any help would be welcomed.










share|improve this question


























  • There is not an initialization in this example.

    – JoseJimRin
    Mar 28 at 9:13






  • 2





    You should use @ViewChild if you want to get reference to the input field.

    – iamjc015
    Mar 28 at 9:15











  • @iamjc015 you're right, now I get the input. But the main problem is that the input event is not triggered when i type on the input.

    – Pierrick Martellière
    Mar 28 at 9:24

















-3















I'm new to Angular5 and searched for hours but couldn't resolve my issue.
Every related threads on SO are not in the same version as me.



I have an input on which I want to trigger a function when something is typed in that input.



Here's my input:



<input
#autocompleteInput
class="inputHeader"
(click)="openSearch()"
placeholder="Coupe homme, lissage brésilen, ..."
/>


Here's my input property declaration:



@Input() autocompleteInput: string;


When I console.log(this.autocompleteInput); in the ngOnInit() method, it display "undefined".



What am I doing wrong ?



Any help would be welcomed.










share|improve this question


























  • There is not an initialization in this example.

    – JoseJimRin
    Mar 28 at 9:13






  • 2





    You should use @ViewChild if you want to get reference to the input field.

    – iamjc015
    Mar 28 at 9:15











  • @iamjc015 you're right, now I get the input. But the main problem is that the input event is not triggered when i type on the input.

    – Pierrick Martellière
    Mar 28 at 9:24













-3












-3








-3








I'm new to Angular5 and searched for hours but couldn't resolve my issue.
Every related threads on SO are not in the same version as me.



I have an input on which I want to trigger a function when something is typed in that input.



Here's my input:



<input
#autocompleteInput
class="inputHeader"
(click)="openSearch()"
placeholder="Coupe homme, lissage brésilen, ..."
/>


Here's my input property declaration:



@Input() autocompleteInput: string;


When I console.log(this.autocompleteInput); in the ngOnInit() method, it display "undefined".



What am I doing wrong ?



Any help would be welcomed.










share|improve this question
















I'm new to Angular5 and searched for hours but couldn't resolve my issue.
Every related threads on SO are not in the same version as me.



I have an input on which I want to trigger a function when something is typed in that input.



Here's my input:



<input
#autocompleteInput
class="inputHeader"
(click)="openSearch()"
placeholder="Coupe homme, lissage brésilen, ..."
/>


Here's my input property declaration:



@Input() autocompleteInput: string;


When I console.log(this.autocompleteInput); in the ngOnInit() method, it display "undefined".



What am I doing wrong ?



Any help would be welcomed.







angular






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 10:27









StefanK

125 bronze badges




125 bronze badges










asked Mar 28 at 9:11









Pierrick MartellièrePierrick Martellière

5159 silver badges30 bronze badges




5159 silver badges30 bronze badges















  • There is not an initialization in this example.

    – JoseJimRin
    Mar 28 at 9:13






  • 2





    You should use @ViewChild if you want to get reference to the input field.

    – iamjc015
    Mar 28 at 9:15











  • @iamjc015 you're right, now I get the input. But the main problem is that the input event is not triggered when i type on the input.

    – Pierrick Martellière
    Mar 28 at 9:24

















  • There is not an initialization in this example.

    – JoseJimRin
    Mar 28 at 9:13






  • 2





    You should use @ViewChild if you want to get reference to the input field.

    – iamjc015
    Mar 28 at 9:15











  • @iamjc015 you're right, now I get the input. But the main problem is that the input event is not triggered when i type on the input.

    – Pierrick Martellière
    Mar 28 at 9:24
















There is not an initialization in this example.

– JoseJimRin
Mar 28 at 9:13





There is not an initialization in this example.

– JoseJimRin
Mar 28 at 9:13




2




2





You should use @ViewChild if you want to get reference to the input field.

– iamjc015
Mar 28 at 9:15





You should use @ViewChild if you want to get reference to the input field.

– iamjc015
Mar 28 at 9:15













@iamjc015 you're right, now I get the input. But the main problem is that the input event is not triggered when i type on the input.

– Pierrick Martellière
Mar 28 at 9:24





@iamjc015 you're right, now I get the input. But the main problem is that the input event is not triggered when i type on the input.

– Pierrick Martellière
Mar 28 at 9:24












5 Answers
5






active

oldest

votes


















2
















Input property is used for component interaction. Here if you want to get the value you entered in input, then you can use



in html:



 <input
#autocompleteInput
class="inputHeader"
(click)="openSearch()"
placeholder="Coupe homme, lissage brésilen, ..."
(input)="inputData($event.target.value)"
/>


in ts:



inputData(data: any) 
console.log(data)






share|improve this answer



























  • Already tried it, input, keyup, or change events are never triggering.

    – Pierrick Martellière
    Mar 28 at 9:25











  • did any of the other answers work?

    – Seba Cherian
    Mar 28 at 9:25











  • Nope :/ Already tried a lot of SO answers

    – Pierrick Martellière
    Mar 28 at 9:26











  • Can you try my updated answer? It worked for me

    – Seba Cherian
    Mar 28 at 9:32












  • Already tried it from @jo_va's answer

    – Pierrick Martellière
    Mar 28 at 9:33


















1
















You should use "keyup" event for the same:



<input
#autocompleteInput
class="inputHeader"
(click)="openSearch()"
placeholder="Coupe homme, lissage brésilen, ..."
(keyup)="methodName($event)"

/>





share|improve this answer

























  • Hi, thanks for your answer but that's not working :/

    – Pierrick Martellière
    Mar 28 at 9:18











  • can you share your code with stackblitz.com so that I can have better understanding?

    – Sumit Vekariya
    Mar 28 at 9:22











  • stackblitz.com/edit/angular-suqctf

    – Pierrick Martellière
    Mar 28 at 9:30


















1
















In ts file



import ViewChild from '@angular/core';

export class tsClass implements OnInit
@ViewChild('autocompleteInput') autocompleteInput;
//now you can user it
this.autocompleteInput = this.autocompleteInput.nativeElement;






share|improve this answer

























  • Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

    – Pierrick Martellière
    Mar 28 at 9:32











  • One question only if not solved yet, you want input because html is in different component right?

    – Pratik
    Mar 29 at 6:02


















1
















autocompleteInput is a reference to your input element, and not the content of your input.
You would have to use it with the ViewChild decorator to get an ElementRef:



@ViewChild('autocompleteInput') inputRef: ElementRef;


From this ElementRef, you can get the native element (HTMLInputElement) with inputRef.nativeElement.



However, if you want to get the text as it is typed in the input, you should use the input event:



<input
#autocompleteInput
type="text"
class="inputHeader"
(input)="onInput($event.target.value)"
placeholder="Coupe homme, lissage brésilen, ..."
/>


onInput(value: string) 
// do something with value



Or use an ngModel to control the value of your input:



<input
#autocompleteInput
type="text"
class="inputHeader"
[ngModel]="value"
(ngModelChange)="valueChanged($event)"
placeholder="Coupe homme, lissage brésilen, ..."
/>


value: string;

valueChanged(value: string)
this.value = value;
// do something with this.value




See this Stackblitz demo




If you are using Ionic, you should use <ion-input> instead of <input>:



<ion-input type="text" (input)="onInput($event.target.value)"></ion-input>





share|improve this answer



























  • You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

    – Pierrick Martellière
    Mar 28 at 9:23











  • This is a strange issue, could share your code via a stackblitz ?

    – jo_va
    Mar 28 at 9:25











  • For sure, wait plz

    – Pierrick Martellière
    Mar 28 at 9:26











  • @Pierrick Martellière, I provided a short stackblitz demo to my answer

    – jo_va
    Mar 28 at 9:29







  • 1





    @Pierrick Martellière, no problem!

    – jo_va
    Mar 28 at 9:53


















1
















Turns out there was another input in the bottom of my template that was used when the first input was clicked. The input event now triggers well.



Sorry for my stupidity and thanks to everyone for the time and patience.






share|improve this answer



























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393810%2fangular-5-why-is-my-input-property-undefined%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2
















    Input property is used for component interaction. Here if you want to get the value you entered in input, then you can use



    in html:



     <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (input)="inputData($event.target.value)"
    />


    in ts:



    inputData(data: any) 
    console.log(data)






    share|improve this answer



























    • Already tried it, input, keyup, or change events are never triggering.

      – Pierrick Martellière
      Mar 28 at 9:25











    • did any of the other answers work?

      – Seba Cherian
      Mar 28 at 9:25











    • Nope :/ Already tried a lot of SO answers

      – Pierrick Martellière
      Mar 28 at 9:26











    • Can you try my updated answer? It worked for me

      – Seba Cherian
      Mar 28 at 9:32












    • Already tried it from @jo_va's answer

      – Pierrick Martellière
      Mar 28 at 9:33















    2
















    Input property is used for component interaction. Here if you want to get the value you entered in input, then you can use



    in html:



     <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (input)="inputData($event.target.value)"
    />


    in ts:



    inputData(data: any) 
    console.log(data)






    share|improve this answer



























    • Already tried it, input, keyup, or change events are never triggering.

      – Pierrick Martellière
      Mar 28 at 9:25











    • did any of the other answers work?

      – Seba Cherian
      Mar 28 at 9:25











    • Nope :/ Already tried a lot of SO answers

      – Pierrick Martellière
      Mar 28 at 9:26











    • Can you try my updated answer? It worked for me

      – Seba Cherian
      Mar 28 at 9:32












    • Already tried it from @jo_va's answer

      – Pierrick Martellière
      Mar 28 at 9:33













    2














    2










    2









    Input property is used for component interaction. Here if you want to get the value you entered in input, then you can use



    in html:



     <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (input)="inputData($event.target.value)"
    />


    in ts:



    inputData(data: any) 
    console.log(data)






    share|improve this answer















    Input property is used for component interaction. Here if you want to get the value you entered in input, then you can use



    in html:



     <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (input)="inputData($event.target.value)"
    />


    in ts:



    inputData(data: any) 
    console.log(data)







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 28 at 9:32

























    answered Mar 28 at 9:18









    Seba CherianSeba Cherian

    1,1981 silver badge14 bronze badges




    1,1981 silver badge14 bronze badges















    • Already tried it, input, keyup, or change events are never triggering.

      – Pierrick Martellière
      Mar 28 at 9:25











    • did any of the other answers work?

      – Seba Cherian
      Mar 28 at 9:25











    • Nope :/ Already tried a lot of SO answers

      – Pierrick Martellière
      Mar 28 at 9:26











    • Can you try my updated answer? It worked for me

      – Seba Cherian
      Mar 28 at 9:32












    • Already tried it from @jo_va's answer

      – Pierrick Martellière
      Mar 28 at 9:33

















    • Already tried it, input, keyup, or change events are never triggering.

      – Pierrick Martellière
      Mar 28 at 9:25











    • did any of the other answers work?

      – Seba Cherian
      Mar 28 at 9:25











    • Nope :/ Already tried a lot of SO answers

      – Pierrick Martellière
      Mar 28 at 9:26











    • Can you try my updated answer? It worked for me

      – Seba Cherian
      Mar 28 at 9:32












    • Already tried it from @jo_va's answer

      – Pierrick Martellière
      Mar 28 at 9:33
















    Already tried it, input, keyup, or change events are never triggering.

    – Pierrick Martellière
    Mar 28 at 9:25





    Already tried it, input, keyup, or change events are never triggering.

    – Pierrick Martellière
    Mar 28 at 9:25













    did any of the other answers work?

    – Seba Cherian
    Mar 28 at 9:25





    did any of the other answers work?

    – Seba Cherian
    Mar 28 at 9:25













    Nope :/ Already tried a lot of SO answers

    – Pierrick Martellière
    Mar 28 at 9:26





    Nope :/ Already tried a lot of SO answers

    – Pierrick Martellière
    Mar 28 at 9:26













    Can you try my updated answer? It worked for me

    – Seba Cherian
    Mar 28 at 9:32






    Can you try my updated answer? It worked for me

    – Seba Cherian
    Mar 28 at 9:32














    Already tried it from @jo_va's answer

    – Pierrick Martellière
    Mar 28 at 9:33





    Already tried it from @jo_va's answer

    – Pierrick Martellière
    Mar 28 at 9:33













    1
















    You should use "keyup" event for the same:



    <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (keyup)="methodName($event)"

    />





    share|improve this answer

























    • Hi, thanks for your answer but that's not working :/

      – Pierrick Martellière
      Mar 28 at 9:18











    • can you share your code with stackblitz.com so that I can have better understanding?

      – Sumit Vekariya
      Mar 28 at 9:22











    • stackblitz.com/edit/angular-suqctf

      – Pierrick Martellière
      Mar 28 at 9:30















    1
















    You should use "keyup" event for the same:



    <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (keyup)="methodName($event)"

    />





    share|improve this answer

























    • Hi, thanks for your answer but that's not working :/

      – Pierrick Martellière
      Mar 28 at 9:18











    • can you share your code with stackblitz.com so that I can have better understanding?

      – Sumit Vekariya
      Mar 28 at 9:22











    • stackblitz.com/edit/angular-suqctf

      – Pierrick Martellière
      Mar 28 at 9:30













    1














    1










    1









    You should use "keyup" event for the same:



    <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (keyup)="methodName($event)"

    />





    share|improve this answer













    You should use "keyup" event for the same:



    <input
    #autocompleteInput
    class="inputHeader"
    (click)="openSearch()"
    placeholder="Coupe homme, lissage brésilen, ..."
    (keyup)="methodName($event)"

    />






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 28 at 9:14









    Sumit VekariyaSumit Vekariya

    1046 bronze badges




    1046 bronze badges















    • Hi, thanks for your answer but that's not working :/

      – Pierrick Martellière
      Mar 28 at 9:18











    • can you share your code with stackblitz.com so that I can have better understanding?

      – Sumit Vekariya
      Mar 28 at 9:22











    • stackblitz.com/edit/angular-suqctf

      – Pierrick Martellière
      Mar 28 at 9:30

















    • Hi, thanks for your answer but that's not working :/

      – Pierrick Martellière
      Mar 28 at 9:18











    • can you share your code with stackblitz.com so that I can have better understanding?

      – Sumit Vekariya
      Mar 28 at 9:22











    • stackblitz.com/edit/angular-suqctf

      – Pierrick Martellière
      Mar 28 at 9:30
















    Hi, thanks for your answer but that's not working :/

    – Pierrick Martellière
    Mar 28 at 9:18





    Hi, thanks for your answer but that's not working :/

    – Pierrick Martellière
    Mar 28 at 9:18













    can you share your code with stackblitz.com so that I can have better understanding?

    – Sumit Vekariya
    Mar 28 at 9:22





    can you share your code with stackblitz.com so that I can have better understanding?

    – Sumit Vekariya
    Mar 28 at 9:22













    stackblitz.com/edit/angular-suqctf

    – Pierrick Martellière
    Mar 28 at 9:30





    stackblitz.com/edit/angular-suqctf

    – Pierrick Martellière
    Mar 28 at 9:30











    1
















    In ts file



    import ViewChild from '@angular/core';

    export class tsClass implements OnInit
    @ViewChild('autocompleteInput') autocompleteInput;
    //now you can user it
    this.autocompleteInput = this.autocompleteInput.nativeElement;






    share|improve this answer

























    • Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

      – Pierrick Martellière
      Mar 28 at 9:32











    • One question only if not solved yet, you want input because html is in different component right?

      – Pratik
      Mar 29 at 6:02















    1
















    In ts file



    import ViewChild from '@angular/core';

    export class tsClass implements OnInit
    @ViewChild('autocompleteInput') autocompleteInput;
    //now you can user it
    this.autocompleteInput = this.autocompleteInput.nativeElement;






    share|improve this answer

























    • Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

      – Pierrick Martellière
      Mar 28 at 9:32











    • One question only if not solved yet, you want input because html is in different component right?

      – Pratik
      Mar 29 at 6:02













    1














    1










    1









    In ts file



    import ViewChild from '@angular/core';

    export class tsClass implements OnInit
    @ViewChild('autocompleteInput') autocompleteInput;
    //now you can user it
    this.autocompleteInput = this.autocompleteInput.nativeElement;






    share|improve this answer













    In ts file



    import ViewChild from '@angular/core';

    export class tsClass implements OnInit
    @ViewChild('autocompleteInput') autocompleteInput;
    //now you can user it
    this.autocompleteInput = this.autocompleteInput.nativeElement;







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 28 at 9:17









    PratikPratik

    1,4711 gold badge9 silver badges7 bronze badges




    1,4711 gold badge9 silver badges7 bronze badges















    • Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

      – Pierrick Martellière
      Mar 28 at 9:32











    • One question only if not solved yet, you want input because html is in different component right?

      – Pratik
      Mar 29 at 6:02

















    • Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

      – Pierrick Martellière
      Mar 28 at 9:32











    • One question only if not solved yet, you want input because html is in different component right?

      – Pratik
      Mar 29 at 6:02
















    Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

    – Pierrick Martellière
    Mar 28 at 9:32





    Right, thanks, but the main problem is that (input), (change) or (keyup) events are not triggered :/

    – Pierrick Martellière
    Mar 28 at 9:32













    One question only if not solved yet, you want input because html is in different component right?

    – Pratik
    Mar 29 at 6:02





    One question only if not solved yet, you want input because html is in different component right?

    – Pratik
    Mar 29 at 6:02











    1
















    autocompleteInput is a reference to your input element, and not the content of your input.
    You would have to use it with the ViewChild decorator to get an ElementRef:



    @ViewChild('autocompleteInput') inputRef: ElementRef;


    From this ElementRef, you can get the native element (HTMLInputElement) with inputRef.nativeElement.



    However, if you want to get the text as it is typed in the input, you should use the input event:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    (input)="onInput($event.target.value)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    onInput(value: string) 
    // do something with value



    Or use an ngModel to control the value of your input:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    [ngModel]="value"
    (ngModelChange)="valueChanged($event)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    value: string;

    valueChanged(value: string)
    this.value = value;
    // do something with this.value




    See this Stackblitz demo




    If you are using Ionic, you should use <ion-input> instead of <input>:



    <ion-input type="text" (input)="onInput($event.target.value)"></ion-input>





    share|improve this answer



























    • You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

      – Pierrick Martellière
      Mar 28 at 9:23











    • This is a strange issue, could share your code via a stackblitz ?

      – jo_va
      Mar 28 at 9:25











    • For sure, wait plz

      – Pierrick Martellière
      Mar 28 at 9:26











    • @Pierrick Martellière, I provided a short stackblitz demo to my answer

      – jo_va
      Mar 28 at 9:29







    • 1





      @Pierrick Martellière, no problem!

      – jo_va
      Mar 28 at 9:53















    1
















    autocompleteInput is a reference to your input element, and not the content of your input.
    You would have to use it with the ViewChild decorator to get an ElementRef:



    @ViewChild('autocompleteInput') inputRef: ElementRef;


    From this ElementRef, you can get the native element (HTMLInputElement) with inputRef.nativeElement.



    However, if you want to get the text as it is typed in the input, you should use the input event:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    (input)="onInput($event.target.value)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    onInput(value: string) 
    // do something with value



    Or use an ngModel to control the value of your input:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    [ngModel]="value"
    (ngModelChange)="valueChanged($event)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    value: string;

    valueChanged(value: string)
    this.value = value;
    // do something with this.value




    See this Stackblitz demo




    If you are using Ionic, you should use <ion-input> instead of <input>:



    <ion-input type="text" (input)="onInput($event.target.value)"></ion-input>





    share|improve this answer



























    • You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

      – Pierrick Martellière
      Mar 28 at 9:23











    • This is a strange issue, could share your code via a stackblitz ?

      – jo_va
      Mar 28 at 9:25











    • For sure, wait plz

      – Pierrick Martellière
      Mar 28 at 9:26











    • @Pierrick Martellière, I provided a short stackblitz demo to my answer

      – jo_va
      Mar 28 at 9:29







    • 1





      @Pierrick Martellière, no problem!

      – jo_va
      Mar 28 at 9:53













    1














    1










    1









    autocompleteInput is a reference to your input element, and not the content of your input.
    You would have to use it with the ViewChild decorator to get an ElementRef:



    @ViewChild('autocompleteInput') inputRef: ElementRef;


    From this ElementRef, you can get the native element (HTMLInputElement) with inputRef.nativeElement.



    However, if you want to get the text as it is typed in the input, you should use the input event:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    (input)="onInput($event.target.value)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    onInput(value: string) 
    // do something with value



    Or use an ngModel to control the value of your input:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    [ngModel]="value"
    (ngModelChange)="valueChanged($event)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    value: string;

    valueChanged(value: string)
    this.value = value;
    // do something with this.value




    See this Stackblitz demo




    If you are using Ionic, you should use <ion-input> instead of <input>:



    <ion-input type="text" (input)="onInput($event.target.value)"></ion-input>





    share|improve this answer















    autocompleteInput is a reference to your input element, and not the content of your input.
    You would have to use it with the ViewChild decorator to get an ElementRef:



    @ViewChild('autocompleteInput') inputRef: ElementRef;


    From this ElementRef, you can get the native element (HTMLInputElement) with inputRef.nativeElement.



    However, if you want to get the text as it is typed in the input, you should use the input event:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    (input)="onInput($event.target.value)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    onInput(value: string) 
    // do something with value



    Or use an ngModel to control the value of your input:



    <input
    #autocompleteInput
    type="text"
    class="inputHeader"
    [ngModel]="value"
    (ngModelChange)="valueChanged($event)"
    placeholder="Coupe homme, lissage brésilen, ..."
    />


    value: string;

    valueChanged(value: string)
    this.value = value;
    // do something with this.value




    See this Stackblitz demo




    If you are using Ionic, you should use <ion-input> instead of <input>:



    <ion-input type="text" (input)="onInput($event.target.value)"></ion-input>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 28 at 9:50

























    answered Mar 28 at 9:17









    jo_vajo_va

    10.1k3 gold badges10 silver badges32 bronze badges




    10.1k3 gold badges10 silver badges32 bronze badges















    • You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

      – Pierrick Martellière
      Mar 28 at 9:23











    • This is a strange issue, could share your code via a stackblitz ?

      – jo_va
      Mar 28 at 9:25











    • For sure, wait plz

      – Pierrick Martellière
      Mar 28 at 9:26











    • @Pierrick Martellière, I provided a short stackblitz demo to my answer

      – jo_va
      Mar 28 at 9:29







    • 1





      @Pierrick Martellière, no problem!

      – jo_va
      Mar 28 at 9:53

















    • You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

      – Pierrick Martellière
      Mar 28 at 9:23











    • This is a strange issue, could share your code via a stackblitz ?

      – jo_va
      Mar 28 at 9:25











    • For sure, wait plz

      – Pierrick Martellière
      Mar 28 at 9:26











    • @Pierrick Martellière, I provided a short stackblitz demo to my answer

      – jo_va
      Mar 28 at 9:29







    • 1





      @Pierrick Martellière, no problem!

      – jo_va
      Mar 28 at 9:53
















    You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

    – Pierrick Martellière
    Mar 28 at 9:23





    You're absolutely right, I already went trying this soution, but the problem is that the input event is never triggered. Do you know what could cause this please ?

    – Pierrick Martellière
    Mar 28 at 9:23













    This is a strange issue, could share your code via a stackblitz ?

    – jo_va
    Mar 28 at 9:25





    This is a strange issue, could share your code via a stackblitz ?

    – jo_va
    Mar 28 at 9:25













    For sure, wait plz

    – Pierrick Martellière
    Mar 28 at 9:26





    For sure, wait plz

    – Pierrick Martellière
    Mar 28 at 9:26













    @Pierrick Martellière, I provided a short stackblitz demo to my answer

    – jo_va
    Mar 28 at 9:29






    @Pierrick Martellière, I provided a short stackblitz demo to my answer

    – jo_va
    Mar 28 at 9:29





    1




    1





    @Pierrick Martellière, no problem!

    – jo_va
    Mar 28 at 9:53





    @Pierrick Martellière, no problem!

    – jo_va
    Mar 28 at 9:53











    1
















    Turns out there was another input in the bottom of my template that was used when the first input was clicked. The input event now triggers well.



    Sorry for my stupidity and thanks to everyone for the time and patience.






    share|improve this answer





























      1
















      Turns out there was another input in the bottom of my template that was used when the first input was clicked. The input event now triggers well.



      Sorry for my stupidity and thanks to everyone for the time and patience.






      share|improve this answer



























        1














        1










        1









        Turns out there was another input in the bottom of my template that was used when the first input was clicked. The input event now triggers well.



        Sorry for my stupidity and thanks to everyone for the time and patience.






        share|improve this answer













        Turns out there was another input in the bottom of my template that was used when the first input was clicked. The input event now triggers well.



        Sorry for my stupidity and thanks to everyone for the time and patience.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 9:55









        Pierrick MartellièrePierrick Martellière

        5159 silver badges30 bronze badges




        5159 silver badges30 bronze badges































            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393810%2fangular-5-why-is-my-input-property-undefined%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현