jeudi 13 juillet 2017

using template div id in an angular if statement

I have a modal with 3 lists that have unique ids

<p class="accordion" ng-class"{active:accordion==2}" ng-click="accordion = 2">COPY from the PARCEL:</p>
<ul class="related_email_list accordion-content" ng-show="accordion==2">
    <li ng-repeat="address in parcelAddressToStk">
        <label for="selectAddress_parcel_">
            <input type="checkbox" name="" class="parcelAddress" id="selectAddress_parcel_" value="" ng-click="selectedAddresses(address);" ng-model="address.isSelected" ng-options="address.AddressID as address.pseudo for address in parcelAddressToStk" />
            <span>
                <b class="int-name"> </b>
                <b></b>
                <b></b>
                <b></b>
            </span>
         </label>
    </li>
</ul>

I want to know if it's possible to use the selectAddress_parcel_ id in an if statement. I've tried

if ($scope["selectAddress_parcel_" + item.AddressID] == true) {

//do something }

which comes back as undefined in the watch list. But if I hard-code 'selectAddress_parcel_56088' in watch I can see the correct object.

Is there an easier way to do this or am I concatenating my if statement incorrectly?

Aucun commentaire:

Enregistrer un commentaire