1 回答

TA貢獻1982條經(jīng)驗 獲得超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指令都會創(chuàng)建一個子作用域,并且因為ng-model它綁定了一個作用域?qū)傩?,所以它將對父作用域隱藏。
添加回答
舉報