Skip to content

add dynamically to page and set data #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hnor opened this issue Aug 28, 2024 · 2 comments
Open

add dynamically to page and set data #78

hnor opened this issue Aug 28, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@hnor
Copy link

hnor commented Aug 28, 2024

hi
how to add select2 with document.createElement('select2')
and set data
tanks

@Zefling
Copy link
Collaborator

Zefling commented Aug 28, 2024

Like this?
https://angular.dev/guide/elements

@Zefling Zefling added the help wanted Extra attention is needed label Aug 28, 2024
@hnor
Copy link
Author

hnor commented Aug 29, 2024

Thank you for your reply
Yes, with the same method. But I test it and didn't work. If possible, please provide a sample code
my code:

          let slc=document.createElement('select2')  as NgElement & WithProperties<{data:[]}>; //alse test with{data:Select2Data}
          slc.id='some id'
          let slc_data:Select2Data=[];
          mydata.forEach((el:any,ix:any)=>{    
            slc_data.push({
              value:ix,
              label: el,
              data: { color: 'white', name: el }
            });
          })
          slc.data!=slc_data;
          parent.appendChild(slc);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants