The task is to create a button dynamically with click event using angular. In these examples when someone clicks on the button then a new button gets created.
The easiest way to create a button in AngularJS is to use the ng-repeat directive. We can easily hook up a repeat logic inside a button click event.
<element ng-repeat="variable in expression"> Contents... </element>
Example: Here we have a counter variable that keeps the count of buttons currently present in the DOM. it gets increased by one each time the main button (GFG) is pressed. the increased count results in a new button generated by ng-repeat.
Output: As we keep on clicking the button, the number of buttons keep on increasing in the DOM:
- How to add input fields dynamically on button click in AngularJS ?
- How to detect click event outside Angular component ?
- How to set radio button checked by button click in AngularJS ?
- How to create a Ripple Effect on Click the Button ?
- Routing in Angular JS using Angular UI Router
- Angular CLI | Angular Project Setup
- Angular 7 | Angular Data Services using Observable
- Adding Angular Material Component to Angular Application
- Difference between Angular 4 and Angular 5
- How to create a radio button similar to toggle button using Bootstrap ?
- What is the use of a double-click event in AngularJs?
- How to add active class on click event in custom list group in Bootstrap 4 ?
- How to call PHP function on the click of a Button ?
- How to load notification alert on top right corner without click of button in bootstrap ?
- How to add a pressed effect on button click in CSS?
- How to click a button on webpage using selenium ?
- How to set checkbox checked on button click in AngularJS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.