Address format in a repeater.

I have a repeater that is providing a list of various groups and their meeting address. The address is a single field of type Address. I would like to format the address so that it displays the street address on one line and the City/State/ZIP on another. So, I assume that I need to fields in the repeater (for the two lines), and then format just the street address on one, and the remaining on another.

How do I format the Address or parse the data in order to accomplish this.

I want:
1234 Any Street, #12, City, State, 12345 USA

to display as:
1234 Any St., #12
City, State 12345

If it’s always formatted as in the above example, then you can do:

$w('#repeater1').onItemReady(($i, iData) => {
    let addressComp = iData.address.formatted.split(', ');
    let addressformat = `${addressComp[0]},     ${addressComp[1]}\n${addressComp[2]}, ${addressComp[3]}, ${addressComp[4]}`;
    $i('#text1').text = addressformat;
}) 

[typos fixed]

Thanks. Two questions.

  1. This code does not appear to be having any impact. If the #text1 object is a connected field, it just shows the unformatted data. If I disconnect it, it shows whatever texted is hard-coded.

  2. I am not new to coding, but I am new to Corvid. I am assuming this is not intended to be nested inside any other function or element. Is there a way to trace/debug the code by outputting status, items, etc.during execution?

  1. Check the “address” field key to your filed key.

  2. It should be inside: $w.onReady(() => {/here/});

  3. You can console.log() the iData, addressComp and addressformat to see if it makes sense.