My goal is to pass a parameter in the URL to a page where a select element is populated dynamically. The parameter that needs to be passed is customerProfile.id. I want to find this id in the select options and have it selected by default. How can I achieve this? I need to check if the customerProfile.id exists and then select the corresponding option. If it doesn't exist, the selection should default to a certain value. The ids are numerical values like 1, 2, 3, etc. Let me know if you require more information.
Below is the code for the select element:
<div class="form-group" id="testpick">
<label for="field_customerProfile">customerProfile</label>
<select class="form-control" id="field_customerProfile" name="customerProfile"
ng-model="rentalAgreement.customerProfile"
ng-options="customerProfile as customerProfile.lastName for customerProfile in customerprofiles track by customerProfile.id">
<option value=""></option>
</select>
</div>
I attempted to set the select option value using AngularJS with '1', which will later be replaced with the actual parameter value.
angular.element('div#testpick select').val('1');