0

I am defining my variable as array and pushing values inside it. When I try to access this variable inside another method and apply push function on it, It says, Push is not defined. When I check the typeof of this variable it shows as String.

Any suggestions?


recipients = [];

....

 handleEmailChange(event) {

        const {name , value , dataset: {recipientIndex} } = event.target;
        this.toAddresses[recipientIndex][name] = value; 

    }

handleChange(event) {
        this.recipients = event.detail.value;
    }

 handleSend(event){

        this.toAddresses.forEach ( (address) => {

            const email = address.emailAddress;
            this.recipients.push(email); // ERRORS OUT
2
  • 1
    Looks like whatever is in event.detail.value in handleChange method is a string. Commented Sep 28, 2022 at 13:21
  • 1
    Thank you fixed it. Commented Sep 28, 2022 at 13:27

1 Answer 1

0

At the end it was a simple fix.

This line of code this.recipients = event.detail.value was converting my array to a string . All I did was initiate a push method and keep it as array.

this.recipients.push(event.detail.value)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.