我想从select get id中设置一个选项,所有其他对象都指向一个指令并显示它。 让我解释: 我正在尝试动态编辑对象" 这是我的obj结构
[
{
nome: "name", //phone company
codigo: "id", //that isn't sequential (14, 16, 29...)
categoria: "category", //cellphone or landline
preco: "price" //float digits
}
]
" Contato"是我的联系对象,结构:
[
{
nome:"name",
telefone:"1233-1233",
data:"2016-06-25T22:03:21.508Z",
operadora:
{
nome:"name",
codigo:"(code)", -> int
categoria:"category",
preco:"(price)" -> float
},
serial:"<H_ZZ<ET9B" -> randomic ASCII generated
}
]
价格是装饰性的,所有的东西都没有意义,只是为了学习&#34;
然后我叫指令:
<ui-accordions>
<ui-accordion ng-repeat="contato in contatos | filter:{nome: criterioBusca} | orderBy:criterioDeOrdenacao:direcaoOrdenacao" username= contato.nome serial= contato.serial telefone= contato.telefone data = contato.data operadora = contato.operadora operadoras=operadoras >
</ui-accordion>
</ui-accordions>
//orderBy:criterioDeOrdenacao: direcaoOrdenacao -> orderBy: orderCritery: orderDirection
//filter:{nome: criterioBusca} -> name: searchCritery
我使用指令&#34; uiAccordions&#34;因为每个可以打开一个手风琴
我使用指令&#34; uiAccordion&#34;获取params并显示外部Url(html文件) 我在html外部文件中选择(指令使用)
<select class="form-control" ng-model="contatoOperadoras" ng-options="operadoraTemp.nome + ' (' + (operadoraTemp.preco | currency) +')' for operadoraTemp in operadoras | orderBy:'nome'">
<option value=""></option> <!-- This is who i want select -->
</select>
我把那个同性恋者放在uiAccordion电话中(看看ui声明)
operadora = contato.operadora
这给我这个contato的实际operadora对象(电话公司)(联系人/用户) 所有这些只是学习,但我无法解决这个问题。我想如果我创建其他param索引并传入选项标签(值),但是如何?
我想要这样的节目 (选择{{operadora.nome}})
很抱歉没有语法英语,但在我的国家/地区,英语是当局鼓励的最后一种语言(比如在高中,就像那样),我自己学习。对代码/语法有任何疑问,请问=)
谢谢你们。 []&#39; S 最好的问候,栾
答案 0 :(得分:1)
(代表OP发布)
我解决了这个问题。
查看:
<select class="form-control" ng-model="operadora" ng-init="operadora = operadoracod" >
<option ng-selected="{{operadora.codigo == operadoracod}}" <!-- here --> ng-repeat = "operadora in operadoras | orderBy:'nome'" value="{{operadora.codigo}}">{{operadora.nome + ' (' + (operadora.preco | currency) +')'}}</option>
</select>
指数:
<ui-accordions>
<ui-accordion ng-repeat="contato in contatos | filter:{nome: criterioBusca} | orderBy:criterioDeOrdenacao:direcaoOrdenacao" username= contato.nome serial= contato.serial telefone= contato.telefone data = contato.data operadoracod = contato.operadora.codigo <!-- here -->operadoras=operadoras >
</ui-accordion>
</ui-accordions>
指令:
scope: {
username: "=",
data: "=",
serial: "=",
telefone: "=",
operadoras: "=",
operadoracod: "=" //here
}