Javascript 将ng模型值指定为cakephp select的默认值

Javascript 将ng模型值指定为cakephp select的默认值,javascript,angularjs,cakephp,Javascript,Angularjs,Cakephp,我正在使用一个函数来获取名字和姓氏的首字母,它工作正常。我现在面临的问题是我在ng重复中应用了这个函数。由于ng repeat生成的列表中的select没有默认值,因此我在empty属性中获取该值。现在我想将ng模型值指定为默认值。 获取首字母的JS函数: function getInitials(attrs,element) { if(attrs.ulabel ){ var x = $(element).find(":selected").text();

我正在使用一个函数来获取名字和姓氏的首字母,它工作正常。我现在面临的问题是我在ng重复中应用了这个函数。由于ng repeat生成的列表中的select没有默认值,因此我在empty属性中获取该值。现在我想将ng模型值指定为默认值。 获取首字母的JS函数:

function getInitials(attrs,element)
{
   if(attrs.ulabel ){  
        var x = $(element).find(":selected").text();                
        console.log(x);
        var seperateWords = x.split(" ");
        var acronym = "";
        for (var i = 0; i < seperateWords.length; i++){
            acronym = (acronym + seperateWords[i].substr(0,1).toUpperCase());
        }

  if(element.parent().parent().find('label').text() ){
               element.parent().parent().find('label').text(acronym);
            } else 
      element.parent().parent().prepend('<label>'+acronym+'</label>');

            }
函数getInitials(属性,元素) { 如果(attrs.ulabel){ var x=$(元素).find(“:selected”).text(); 控制台日志(x); var separatewords=x.split(“”); var首字母缩写=”; for(var i=0;i 查看文件:

<ul ng-repeat=" opts in rootEntry['customer']  track by $index" class="sidebar_overview">
                <li class="inner-sidebar">   
                    <ul class ="inner_sidebar_check">
                        <li class="custov_chk">
                            <?php 
                            echo $this->Form->checkbox('cid', array('hiddenField' => false, 'value' => '{{opts.Customer.customerid}}', 'ng-model' => "opts.Selected")); 
                            ?>
                        </li>
                        <li class="co_cn" ng-click="gotoprofile(opts.Customer.customerid)">{{opts.CustomerProfile.firstname | limitTo: 8}} {{opts.CustomerProfile.lastname | limitTo: 8}}</li>
                        <li class="inner_cust_date">{{opts.Customer.addedon}}</li> 
                    </ul>
                </li> 
                <li ng-class-odd="'list1'" ng-class-even="'list2'">
                    <div ng-style="resizeWithOffset(300,220,150);" class="outer-sidebar label-outer-sidebar">
                        <ul>
                            <li class="col-lg-2 col-md-2 col-sm-6 col-xs-6"><?php
                                echo $this->Acs->userdropdown('allocatedtoprimaryid', array('label' => False, 'type' => 'select',
                                    'utype' => 'salesman',
                                    'anlabel' => true,
                                    'ng-model' => 'opts.AddedbyCustomer.allocatedtoprimaryid',
                                    'empty' => 'Salesman 1',
                                    'ng-hasfocus' => 'prime','ulabel' => 'true','class'=>'usr_drp_prime'
                                ));
                                ?>
                            </li>
                            <li class="col-lg-2 col-md-2 col-sm-0 col-xs-0"><?php
                                echo $this->Acs->userdropdown('allocatedtosecondaryid', array('label' => False, 'type' => 'select',
                                    'utype' => 'salesman',
                                    'anlabel' => true,
                                    'ng-model' => 'opts.AddedbyCustomer.allocatedtosecondaryid',
                                    'empty' => 'Salesman 2',
                                    'ng-hasfocus' => 'prime','ulabel' => 'true','class'=>'usr_drp_second'
                                ));
                                ?>
                            </li>
                            <li class="col-lg-2 col-md-2 col-sm-0 col-xs-0"><?php
                                echo $this->Form->input('action_seq_id', array('label' => False, 'type' => 'select',
                                    'options' => Configure::read('actionseq1'),
                                    'ng-model' => 'opts.AllocateActionSequenceFrontend.action_seq_id',
                                    'empty' => 'Select Action Sequence',
                                ));
                                ?>
                            </li>
                            <li class="col-lg-2 col-md-2 col-sm-0 col-xs-0"><?php
                                echo $this->Form->input('interestedinid', array('label' => False, 'type' => 'select',
                                    'options' => Configure::read('iaminterstedin'),
                                    'ng-model' => 'opts.CustomerDisposition.interestedinid',
                                    'empty' => 'Select Interested In',
                                ));
                                ?>
                            </li>
                            <li class="col-lg-3 col-md-2 col-sm-0 col-xs-0 src_tag">
                                <span>{{opts.SourceBackend.sourcename}}</span>
                                <span ng-bind="getButtonLabel(opts.CustomerDisposition.tagid)"></span>
                            </li>
                            <li class="col-lg-1 col-md-2 col-sm-6 col-xs-6 pull-right">
                                <div class="custov_action pull-right">
                                    <?php echo $this->Html->link('',array('controller' => 'Customers', 'action' => 'edit/{{opts.Customer.customerid}}/frommini','full_base' => true,), array('id' => 'custov_edit'));
                                          echo $this->Html->link('',array('controller' => 'Lead', 'action' => 'sethotleads/{{opts.Customer.customerid}}hotlead={{opts.CustomerProfile.hot_leads}}','full_base' => true,),array('id'=>'custov_lead'));
                                          echo $this->Html->link('',array('controller' => 'Customers', 'action' => 'custdelete_popup/{{opts.Customer.customerid}}/' . $_SESSION['user_id']), array('id'=>'custov_delete'));
                                    ?>
                                </div>

                            </li>
                        </ul>
                    </div>    
                </li>
            </ul>
    • {{opts.CustomerProfile.firstname}{{opts.CustomerProfile.lastname}{limitTo:8}
    • {{opts.Customer.addedon}}
    • {{opts.SourceBackend.sourcename}