本文介绍了如何自动选择值angularjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下拉列表为空白,我要自动选择值Richard,这是怎么做的,我是新来的.

drop down are blank i want auto selected value Richard how do this, i am new in angular

  <select class="form-control" name="customer" id="customer" ng-model="postjobcustomerCtrl.selectedCustomer" ng-options="customer.full_name for customer in postjobcustomerCtrl.atlasCustomers  | filter:{full_name: Profile.full_name} track by customer.user_id"
ng-change="postjobcustomerCtrl.selectDefaultAddress()" required></select>

推荐答案

在您的 postjobcustomerCtrl 中,初始化选择的 ng-model ( postjobcustomerCtrl.selectedCustomer )和 Richard id .

In your postjobcustomerCtrl, initialize the select ng-model (postjobcustomerCtrl.selectedCustomer) with the id of Richard.

// angularjs controller

atlasCustomers = [{full_name : "Richard", user_id: 1}]        
postjobcustomerCtrl.selectedCustomer = atlasCustomers[0].atlasCustomers.user_id;

这篇关于如何自动选择值angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 17:19