question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Programmatically generated html code not working. (click)= Pipe Filter Render Event Button

See original GitHub issue

I’m submitting a … (check one with “x”)

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

See here for more details: https://forum.ionicframework.com/t/programmatically-generated-html-code-not-working-click-pipe-filter-render-event-button/50783

HTML buttons are created, but onclick event does not get fired. The buttons are in the HTML but there is no click action.

Expected/desired behavior HTML buttons are created, AND onclick event does get fired as in Angular 1.

Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).

What is the expected behavior? HTML buttons are created with onclick events.

What is the motivation / use case for changing the behavior?

It must be possible to create buttons with onclick events on-the-fly reading from an input file JSON. Stream is from well known source (locally). So it is not a security issue. The contents is: “Blabla … (12) … bla bla.”

This should give this output: “Blabla … <button id=“12” (click)=“doAction(‘12’);”>12</button> … bla bla.”

So the only pattern is (n) where n is an integer, whole positive number as in “N”.

Please tell us about your environment:

  • Angular version: 2.0.0-beta.25
  • Browser: [all ]
  • Language: [all ]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:29 (12 by maintainers)

github_iconTop GitHub Comments

7reactions
flagsoftcommented, Jun 1, 2018

@mlc-mlapis write down a solution. “12” is just an example and is variable and comes from the input stream / file locally. So it must be able to SCAN (where “n” is an integer, 1…n)

"(n)"

and transform it to

"(< button id="n" onclick="doAction('n');" >n)".
6reactions
elroyshillingcommented, Jan 9, 2018

A solution using Pipe and Directive: Stackoverflow Plunker Demo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programmatically generated html code not working. (click ...
I managed to get the HTML code interpreted and does render a button, but the (click) does not get fired, so no action....
Read more >
Click event is not working in dynamically generated HTML ...
I think there is a solution for your case: render dynamic code from server. Main idea that you need to create an anonymous...
Read more >
Localization: How to change the displayable text of the Command ...
Hello,. We need to change the displayable text on a few command buttons and labels in our application. We use string resources in...
Read more >
Angular — How to render HTML containing ... - Talentica
Are you thinking of rendering HTML containing Angular Components dynamically? Learn more on a significant subset of supporting dynamic ...
Read more >
Pipe Documentation | addpipe.com
tags) to avoid the page not rendering until pipe.js and pipe.css are loaded. ... After you enter your desired size, press the "Generate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found