1 回答
TA贡献1982条经验 获得超2个赞
仅使用一个控制器:
<body ng-controller="Configurator">
<div ̶n̶g̶-̶c̶o̶n̶t̶r̶o̶l̶l̶e̶r̶=̶"̶C̶o̶n̶f̶i̶g̶u̶r̶a̶t̶o̶r̶"̶ >
<select multiple ng-model="selected"
ng-options="x.name for x in fields">
</select>
</div>
{{selected}}
<button ̶n̶g̶-̶c̶o̶n̶t̶r̶o̶l̶l̶e̶r̶=̶"̶C̶o̶n̶f̶i̶g̶u̶r̶a̶t̶o̶r̶"̶ ng-click="move() ">Move</button>
<div ̶n̶g̶-̶c̶o̶n̶t̶r̶o̶l̶l̶e̶r̶=̶"̶C̶o̶n̶f̶i̶g̶u̶r̶a̶t̶o̶r̶"̶ >
<select multiple ng-model="selected2"
ng-options="x.name for x in chosen">
</select>
</div>
</body>
每个ng-controller指令都会创建一个子作用域,并且因为ng-model它绑定了一个作用域属性,所以它将对父作用域隐藏。
添加回答
举报
