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;
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);
add a comment |
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);
add a comment |
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);
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);
asked Mar 23 at 19:41
thrasheadthrashead
96211
96211
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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:
Thank you man :)
– thrashead
Mar 23 at 19:49
@thrashead : glad it helped :)
– Pranav C Balan
Mar 23 at 19:50
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
Thank you man :)
– thrashead
Mar 23 at 19:49
@thrashead : glad it helped :)
– Pranav C Balan
Mar 23 at 19:50
add a comment |
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:
Thank you man :)
– thrashead
Mar 23 at 19:49
@thrashead : glad it helped :)
– Pranav C Balan
Mar 23 at 19:50
add a comment |
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:
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:
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
