Doesn't working when assign data on click event
See original GitHub issueI want to assign data(colors) on click event but It is doesn’t work this moment. so please review my code and let me know. how it’s work.
==== TYPESCRIPT CODE ====
public items:Array<any> = [];
addColors(){
COLORS.forEach((color:{name:string, hex:string}) => {
debugger
this.items.push({
id: color.hex,
text: `<colorbox style='background-color:${color.hex};'></colorbox>${color.name} (${color.hex})`
});
console.log(color.name);
});
OR
this.items = [
{'name': 'Blue 1', 'hex': '#AAA'},
{'name': 'Blue 2', 'hex': '#C0E6FF'},
{'name': 'Blue 3', 'hex': '#C0E6FF'}
];
}
===== HTML CODE ====
<div style="width: 200px;margin-top: 10px;">
<ng-select [allowClear]="true"
[items]="colors"
formControlName="items"
(data)="refreshValue($event)"
(selected)="selected($event)"
(removed)="removed($event)"
(typed)="typed($event)"
placeholder="No color selected">
</ng-select>
</div>
<div><button type="button" (click)="addColors()">Add Colors</button></div>
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Click Event is not Working When Data loads Dynamic in jquery
i have debug issue find i have used click function on class so when page loads browser assign class to html (click works)....
Read more >Element: click event - Web APIs | MDN
An element receives a click event when a pointing device button (such as a mouse's primary mouse button) is both pressed and released...
Read more >Introduction to browser events - The Modern JavaScript Tutorial
An event is a signal that something has happened. All DOM nodes generate such signals (but events are not limited to DOM).
Read more >HTML Button onclick – JavaScript Click Event Tutorial
The onclick event executes a certain functionality when a button is clicked. This could be when a user submits a form, when you...
Read more >When a Click is Not Just a Click | CSS-Tricks
The click event is usually tied to a pointer device, typically the mouse, and yet here the Space or Enter key are triggering...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think there are 2 issues in your code.
[items]="items"
async
pipe. Something like[items]="items$ | async"
Yes,its working well, thanks.