对象不能在angularjs ng-model中访问
Object can not access in angularjs ng-model?
我想根据用户从客户端列表中选择客户端来显示客户端 ID 和国家/地区,我可以显示整个选定的对象,但不能显示选定的客户端详细信息。
<label class="control-label red">Client</label>
{{selectedClient}}
<select class="form-control" ng-model="selectedClient">
<option ng-repeat="client in clients" value="{{client.id}}">{{client.name}}</option>
</select>
<a href="javascript:void(0)" data-toggle="modal" data-target="#addressModel"><i class="fa fa-map-marker"></i>
{{selectedClient.id}},{{selectedClient.address_info.country}}
</a>
在这里,selectedClient
从选择框中相应地显示,但是即使它们持有某些值,selectedClient.id
和selectedClient.address_info.country
也不会显示。
选定客户端的输出为,
{
"id": 127,
"payment_terms_id": null,
"name": "Shihabs company",
"note": null,
"created_by": 0,
"updated_by": null,
"deleted_by": null,
"created_at": "2015-03-09 10:32:31",
"updated_at": "2015-03-09 10:32:31",
"deleted_at": null,
"status": 1,
"payment_term": null,
"address_info": {
"id": 54,
"client_id": 127,
"street": null,
"city": null,
"pobox": null,
"country": null,
"phone": null,
"work_phone": null,
"mobile": null,
"email": null,
"website": null,
"billing_street": null,
"billing_city": null,
"billing_pobox": null,
"billing_country": null,
"billing_phone": null,
"billing_work_phone": null,
"billing_mobile": null,
"billing_email": null,
"shipping_street": null,
"shipping_city": null,
"shipping_pobox": null,
"shipping_country": null,
"shipping_phone": null,
"shipping_work_phone": null,
"shipping_mobile": null,
"shipping_email": null,
"created_by": null,
"updated_by": null,
"deleted_by": null,
"created_at": "2015-03-09 10:32:31",
"updated_at": "2015-03-09 10:32:31",
"deleted_at": null,
"status": 1
}
}
尝试这种方式绑定选择选项
<select ng-model="selectedClient" ng-options="client.name for client in
clients"></select>
相关文章:
- 访问ng repeat中的第一个项目
- 从 Javascript 中设置 ng-model name
- 使用 ng-repeat访问 ng 表单元素/值
- Toggle Switch在包含ng model和ng repeat之后不进行切换
- 在Angularjs中,我如何使用ng repeat、ng model和ng click来动态更改内容
- 当与之关联的 ng-model 为 false 时,Angularjs 复选框值不会取消选中
- 在控制器中访问 ng-重复$first属性
- ng-model 绑定到选择标签生成的空默认值
- 对象不能在angularjs ng-model中访问
- 使用 angularjs 访问控制器中的 ng-model 数据
- 角度显示输入基础复选框 ng-model 使输入无法访问
- 无法访问 AngularJS 中 ng-model 之外的变量
- AngularJS -访问一个带有ng-model动态名称的输入数组
- 访问Angular中通过隔离作用域创建的ng-model
- 从组件中的控制器访问html中的ng-model
- Angular无法从json中访问ng-model
- 我不能从控制器[AngularJS]访问ng-model
- 从指令链接函数内部访问ng-model
- 无法访问bind-unsafe-html的ng-model变量的值
- Angularjs从$作用域外访问ng-model