Click event does not send value of parameterHow can I close a dropdown on click outside?Angular : Detect click event inside a div with ngFor insideConfigure an Observable to return all previous values as an array when a new value is pushed?angular2/ionic2 how to use *ngFor parameter in a function callHow to add click event in angular 2 when rendering text in [innerHTML]d3 Click Events Not FiringHide/show a table row when clicking on a link in Angular2Angular 2 Click event with parameter and return valueHostlistener scroll event not firingUpgrade to Angular 6, HostListener is not capturing events raised from JavaScript

How would a physicist explain this starship engine?

Old robot movie with robots in cages being hurt at a carnival show

Schwa-less Polysyllabic German Noun Stems of Germanic Origin

Warped chessboard

Why does an injection from a set to a countable set imply that set is countable?

How to use Screen Sharing if I don't know the remote Mac's IP address

1950s or earlier book with electrical currents living on Pluto

Do dirty bird feeders make birds sick?

How to prove the emptiness of intersection of two context free languages is undecidable?

Differential of a one-form eating a vector?

Can't think of a good word or term to describe not feeling or thinking

How to become an Editorial board member?

Does science define life as "beginning at conception"?

Is there a realtime, uncut video of Saturn V ignition through tower clear?

What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?

Will this series of events work to drown the Tarrasque?

How did Arya and the Hound get into King's Landing so easily?

Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario?

How to say "invitation for war"?

Was Tyrion always a poor strategist?

Is being an extrovert a necessary condition to be a manager?

Keeping the dodos out of the field

Farthing / Riding

If you attack a Tarrasque while swallowed, what AC do you need to beat to hit it?



Click event does not send value of parameter


How can I close a dropdown on click outside?Angular : Detect click event inside a div with ngFor insideConfigure an Observable to return all previous values as an array when a new value is pushed?angular2/ionic2 how to use *ngFor parameter in a function callHow to add click event in angular 2 when rendering text in [innerHTML]d3 Click Events Not FiringHide/show a table row when clicking on a link in Angular2Angular 2 Click event with parameter and return valueHostlistener scroll event not firingUpgrade to Angular 6, HostListener is not capturing events raised from JavaScript






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I try to send some values in onclick event of some links. Onclick event fires but it doesn't send any parameter.



<a *ngFor="let item of langs" href="javascript:;" (onclick)="onClick(item.Lang)">item.Name</a>

@HostListener("click")
onClick(lang: string)
this._eService.chanegeLang(lang)
.subscribe(resData => this.DoIt(),
resError => this.errorMsg = resError);










share|improve this question




























    1















    I try to send some values in onclick event of some links. Onclick event fires but it doesn't send any parameter.



    <a *ngFor="let item of langs" href="javascript:;" (onclick)="onClick(item.Lang)">item.Name</a>

    @HostListener("click")
    onClick(lang: string)
    this._eService.chanegeLang(lang)
    .subscribe(resData => this.DoIt(),
    resError => this.errorMsg = resError);










    share|improve this question
























      1












      1








      1








      I try to send some values in onclick event of some links. Onclick event fires but it doesn't send any parameter.



      <a *ngFor="let item of langs" href="javascript:;" (onclick)="onClick(item.Lang)">item.Name</a>

      @HostListener("click")
      onClick(lang: string)
      this._eService.chanegeLang(lang)
      .subscribe(resData => this.DoIt(),
      resError => this.errorMsg = resError);










      share|improve this question














      I try to send some values in onclick event of some links. Onclick event fires but it doesn't send any parameter.



      <a *ngFor="let item of langs" href="javascript:;" (onclick)="onClick(item.Lang)">item.Name</a>

      @HostListener("click")
      onClick(lang: string)
      this._eService.chanegeLang(lang)
      .subscribe(resData => this.DoIt(),
      resError => this.errorMsg = resError);







      angular






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 19:41









      thrasheadthrashead

      96211




      96211






















          1 Answer
          1






          active

          oldest

          votes


















          1














          It's actually working based on the Decorator(@HostListener) in your case, where the first argument would be eventName as per documentation.



          To make it work use click event in the template, there is no need for on prefix.



          Template :



          <a *ngFor="let item of langs" href="javascript:;" (click)="onClick(item.Lang)">item.Name</a>


          TS :



          onClick(lang: string) 
          this._eService.chanegeLang(lang)
          .subscribe(
          resData => this.DoIt(),
          resError => this.errorMsg = resError
          );



          As per angular docs :




          Angular event binding syntax consists of a target event name within parentheses on the left of an equal sign, and a quoted template statement on the right. The following event binding listens for the button's click events, calling the component's onSave() method whenever a click occurs:
          enter image description here







          share|improve this answer

























          • Thank you man :)

            – thrashead
            Mar 23 at 19:49











          • @thrashead : glad it helped :)

            – Pranav C Balan
            Mar 23 at 19:50











          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/3.0/"u003ecc by-sa 3.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%2f55317657%2fclick-event-does-not-send-value-of-parameter%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          It's actually working based on the Decorator(@HostListener) in your case, where the first argument would be eventName as per documentation.



          To make it work use click event in the template, there is no need for on prefix.



          Template :



          <a *ngFor="let item of langs" href="javascript:;" (click)="onClick(item.Lang)">item.Name</a>


          TS :



          onClick(lang: string) 
          this._eService.chanegeLang(lang)
          .subscribe(
          resData => this.DoIt(),
          resError => this.errorMsg = resError
          );



          As per angular docs :




          Angular event binding syntax consists of a target event name within parentheses on the left of an equal sign, and a quoted template statement on the right. The following event binding listens for the button's click events, calling the component's onSave() method whenever a click occurs:
          enter image description here







          share|improve this answer

























          • Thank you man :)

            – thrashead
            Mar 23 at 19:49











          • @thrashead : glad it helped :)

            – Pranav C Balan
            Mar 23 at 19:50















          1














          It's actually working based on the Decorator(@HostListener) in your case, where the first argument would be eventName as per documentation.



          To make it work use click event in the template, there is no need for on prefix.



          Template :



          <a *ngFor="let item of langs" href="javascript:;" (click)="onClick(item.Lang)">item.Name</a>


          TS :



          onClick(lang: string) 
          this._eService.chanegeLang(lang)
          .subscribe(
          resData => this.DoIt(),
          resError => this.errorMsg = resError
          );



          As per angular docs :




          Angular event binding syntax consists of a target event name within parentheses on the left of an equal sign, and a quoted template statement on the right. The following event binding listens for the button's click events, calling the component's onSave() method whenever a click occurs:
          enter image description here







          share|improve this answer

























          • Thank you man :)

            – thrashead
            Mar 23 at 19:49











          • @thrashead : glad it helped :)

            – Pranav C Balan
            Mar 23 at 19:50













          1












          1








          1







          It's actually working based on the Decorator(@HostListener) in your case, where the first argument would be eventName as per documentation.



          To make it work use click event in the template, there is no need for on prefix.



          Template :



          <a *ngFor="let item of langs" href="javascript:;" (click)="onClick(item.Lang)">item.Name</a>


          TS :



          onClick(lang: string) 
          this._eService.chanegeLang(lang)
          .subscribe(
          resData => this.DoIt(),
          resError => this.errorMsg = resError
          );



          As per angular docs :




          Angular event binding syntax consists of a target event name within parentheses on the left of an equal sign, and a quoted template statement on the right. The following event binding listens for the button's click events, calling the component's onSave() method whenever a click occurs:
          enter image description here







          share|improve this answer















          It's actually working based on the Decorator(@HostListener) in your case, where the first argument would be eventName as per documentation.



          To make it work use click event in the template, there is no need for on prefix.



          Template :



          <a *ngFor="let item of langs" href="javascript:;" (click)="onClick(item.Lang)">item.Name</a>


          TS :



          onClick(lang: string) 
          this._eService.chanegeLang(lang)
          .subscribe(
          resData => this.DoIt(),
          resError => this.errorMsg = resError
          );



          As per angular docs :




          Angular event binding syntax consists of a target event name within parentheses on the left of an equal sign, and a quoted template statement on the right. The following event binding listens for the button's click events, calling the component's onSave() method whenever a click occurs:
          enter image description here








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 23 at 19:51

























          answered Mar 23 at 19:45









          Pranav C BalanPranav C Balan

          92.6k1593120




          92.6k1593120












          • Thank you man :)

            – thrashead
            Mar 23 at 19:49











          • @thrashead : glad it helped :)

            – Pranav C Balan
            Mar 23 at 19:50

















          • Thank you man :)

            – thrashead
            Mar 23 at 19:49











          • @thrashead : glad it helped :)

            – Pranav C Balan
            Mar 23 at 19:50
















          Thank you man :)

          – thrashead
          Mar 23 at 19:49





          Thank you man :)

          – thrashead
          Mar 23 at 19:49













          @thrashead : glad it helped :)

          – Pranav C Balan
          Mar 23 at 19:50





          @thrashead : glad it helped :)

          – Pranav C Balan
          Mar 23 at 19:50



















          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%2f55317657%2fclick-event-does-not-send-value-of-parameter%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

          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

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해