Answers.Body: <p>Try below code</p>
  <pre><code>&lt;div crm-ui-field=&quot;{name: 'myForm.location_province', title: ts('Province')}&quot;&gt;
    &lt;input
      name=&quot;myForm.location_province&quot; crm-ui-id=&quot;myForm.location_province&quot; 
       crm-entityref=&quot;{entity: 'state_province', api: {params: {country_id: 1039, is_active: 1, options:{sort:\'name\'}}}, select: {allowClear: true, minimumInputLength: 0, placeholder: ts(\'Select State\')}}&quot;
      ng-model=&quot;myForm.location_province&quot;
    /&gt;
  &lt;/div&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-04T12:55:07.323Z
Answers.Text: Thanks!  Exactly what I was looking for.
Answers.UserDisplayName: Norm Dressler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-04T07:41:28.627Z
Answers.LastActivityDate: 2021-06-04T07:41:28.627Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm trying to change some forms from quickforms to angularjs.<br />
  In quickforms you do this:
  $this-&gt;addEntityRef('Location_province', ts('Select Province'),
  ['entity' =&gt; 'state_province',]);</p>
  <p>How do I replicate this in Angularjs?  This is what I thought I should do but probably a class or something in CRM to already do this:
  In js file:</p>
  <pre><code>provinces = crmApi('state_province', 'get', {
        country_id: 1039,
      })
  // do I process provinces to get to the values I want?
  this.province = provinces
  var ctrl = this
  </code></pre>
  <p>In the html template file I have:</p>
  <pre><code>&lt;div crm-ui-field=&quot;{name: 'myForm.location_province', title: ts('Province'),}&quot;&gt;
              &lt;select
                crm-ui-select=&quot;{allowClear: true}&quot;
                ng-model=&quot;$ctrl.myContact.location_province&quot;
                multiple=&quot;single&quot;
                class=&quot;big&quot;
              &gt;
                &lt;option ng-repeat=&quot;option in $ctrl.province.values&quot; value=&quot;{{option.name}}&quot;&gt;
                {{option.name}}
              &lt;/option&gt;
              &lt;/select&gt;
              {{myform.location_province}}
            &lt;/div&gt;
  </code></pre>
  <p>So its not working because the crmApi returns it in an array of multiple levels so is there a class to do this for me?</p>
  <p>Thanks in advance!</p>
  
Tags: <civicrm-entity><angular>
Title: Using a dropdown box for selecting stateprovice?
ThreadText: # Using a dropdown box for selecting stateprovice?
  
  (Asked by: username_0 on 2021-06-03)
  
  I'm trying to change some forms from quickforms to angularjs.  
  In quickforms you do this:
  $this->addEntityRef('Location\_province', ts('Select Province'),
  ['entity' => 'state\_province',]);
  
  How do I replicate this in Angularjs? This is what I thought I should do but probably a class or something in CRM to already do this:
  In js file:
  
  ```
  provinces = crmApi('state_province', 'get', {
        country_id: 1039,
      })
  // do I process provinces to get to the values I want?
  this.province = provinces
  var ctrl = this
  
  ```
  
  In the html template file I have:
  
  ```
  <div crm-ui-field="{name: 'myForm.location_province', title: ts('Province'),}">
              <select
                crm-ui-select="{allowClear: true}"
                ng-model="$ctrl.myContact.location_province"
                multiple="single"
                class="big"
              >
                <option ng-repeat="option in $ctrl.province.values" value="{{option.name}}">
                {{option.name}}
              </option>
              </select>
              {{myform.location_province}}
            </div>
  
  ```
  
  So its not working because the crmApi returns it in an array of multiple levels so is there a class to do this for me?
  
  Thanks in advance!
  
  **Tags:** civicrm-entity, angular
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-04. Score: 1 | Accepted answer
  
  Try below code
  
  ```
  <div crm-ui-field="{name: 'myForm.location_province', title: ts('Province')}">
    <input
      name="myForm.location_province" crm-ui-id="myForm.location_province" 
       crm-entityref="{entity: 'state_province', api: {params: {country_id: 1039, is_active: 1, options:{sort:\'name\'}}}, select: {allowClear: true, minimumInputLength: 0, placeholder: ts(\'Select State\')}}"
      ng-model="myForm.location_province"
    />
  </div>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks!  Exactly what I was looking for.  
  
  ---
  
  