如何自动选择值angularjs [英] how to auto selected value angularjs

查看:24
本文介绍了如何自动选择值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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆