md-select angular js更新多个值
md-select angular js updates multiple values
这是我的代码,我正在尝试 select 根据日期为楼层和班次设置不同的值。
<div class="card whiteBckg" ng-repeat="(key, value) in requestsObj" ng-if="true">
<div class="cardHeaderDiv">
<h4>{{key}} <span>X</span></h4>
</div>
<div class="cardBodyDiv" ng-repeat="(k, v) in value">
<md-select ng-model="v.shift" placeholder="Select Shift" required md-no-asterisk="false">
<md-option ng-value="tm.shiftid" ng-repeat="tm in shifts">{{ tm.shift }}</md-option>
</md-select>
<md-select ng-model="v.floor" placeholder="Select Floor" required md-no-asterisk="false">
<md-option ng-value="fl.id" ng-repeat="fl in floors">{{ fl.floor }}</md-option>
</md-select>
<div ng-repeat="(a, b) in v.type" class="chip">
<i class="fa fa-clock-o"></i>{{ getTotal(key, k, a) }} {{a}}
</div>
</div>
<div class="cardFooterDiv">
<h4>Add more shifts for this day</h4>
</div>
</div>
$scope.shifts = [{shiftid: "a", shift: "A"}, {shiftid: "c", shift: "C"}, { shiftid: "b", shift: "B"}];
$scope.floors = [{id: "f1", floor: "F1"}, {id: "f2", floor: "F2"}, {编号:"f3",楼层:"F3"}];
[{
"shift":空,
"floor":空,
"type": typeObj
},{
"shift":空,
"floor":空,
"type": typeObj
},{
"shift":空,
"floor":空,
"type": typeObj
}];
当我有多张卡片并且我选择其中一个班次时,所有班次都会更新为相同的值。enter image description here
我附上了一张图片任何人都可以帮忙!!!!!!谢谢。
我在你的模板中删除了这一行 <div class="cardBodyDiv" ng-repeat="(k, v) in value">
的重复,将 type: typeObj
设置为 type: {}
进行测试,并在控制器的 $onInit 方法中创建了这些变量。它对我有用。
控制器
this.shifts = [{shiftid: 'a', shift: 'A'}, {shiftid: 'b', shift: 'B'}, {shiftid: 'c', shift: 'C'}];
this.floors = [{id: 'f1', floor: 'F1'}, {id: 'f2', floor: 'F2'}, {id: 'f3', floor: 'F3'}];
this.requestsObj = [{ shift: null, floor: null, type: {} }, { shift: null, floor: null, type: {} }, { shift: null, floor: null, type: {} }];
模板
<div class="card whiteBckg" ng-repeat="(key, value) in $ctrl.requestsObj" ng-if="true">
<div class="cardHeaderDiv">
<h4>{{key}}
<span>X</span>
</h4>
</div>
<div class="cardBodyDiv">
<md-select ng-model="value.shift" placeholder="Select Shift" required md-no-asterisk="false">
<md-option ng-value="tm.shiftid" ng-repeat="tm in $ctrl.shifts">{{ tm.shift }}</md-option>
</md-select>
<md-select ng-model="value.floor" placeholder="Select Floor" required md-no-asterisk="false">
<md-option ng-value="fl.id" ng-repeat="fl in $ctrl.floors">{{ fl.floor }}</md-option>
</md-select>
<div ng-repeat="(a, b) in value.type" class="chip">
<i class="fa fa-clock-o"></i>{{ getTotal(key, k, a) }} {{a}}
</div>
</div>
<div class="cardFooterDiv">
<h4>Add more shifts for this day</h4>
</div>
</div>
屏幕截图
这是我的代码,我正在尝试 select 根据日期为楼层和班次设置不同的值。
<div class="card whiteBckg" ng-repeat="(key, value) in requestsObj" ng-if="true">
<div class="cardHeaderDiv">
<h4>{{key}} <span>X</span></h4>
</div>
<div class="cardBodyDiv" ng-repeat="(k, v) in value">
<md-select ng-model="v.shift" placeholder="Select Shift" required md-no-asterisk="false">
<md-option ng-value="tm.shiftid" ng-repeat="tm in shifts">{{ tm.shift }}</md-option>
</md-select>
<md-select ng-model="v.floor" placeholder="Select Floor" required md-no-asterisk="false">
<md-option ng-value="fl.id" ng-repeat="fl in floors">{{ fl.floor }}</md-option>
</md-select>
<div ng-repeat="(a, b) in v.type" class="chip">
<i class="fa fa-clock-o"></i>{{ getTotal(key, k, a) }} {{a}}
</div>
</div>
<div class="cardFooterDiv">
<h4>Add more shifts for this day</h4>
</div>
</div>
$scope.shifts = [{shiftid: "a", shift: "A"}, {shiftid: "c", shift: "C"}, { shiftid: "b", shift: "B"}];
$scope.floors = [{id: "f1", floor: "F1"}, {id: "f2", floor: "F2"}, {编号:"f3",楼层:"F3"}];
[{ "shift":空, "floor":空, "type": typeObj },{ "shift":空, "floor":空, "type": typeObj },{ "shift":空, "floor":空, "type": typeObj }];
当我有多张卡片并且我选择其中一个班次时,所有班次都会更新为相同的值。enter image description here
我附上了一张图片任何人都可以帮忙!!!!!!谢谢。
我在你的模板中删除了这一行 <div class="cardBodyDiv" ng-repeat="(k, v) in value">
的重复,将 type: typeObj
设置为 type: {}
进行测试,并在控制器的 $onInit 方法中创建了这些变量。它对我有用。
控制器
this.shifts = [{shiftid: 'a', shift: 'A'}, {shiftid: 'b', shift: 'B'}, {shiftid: 'c', shift: 'C'}];
this.floors = [{id: 'f1', floor: 'F1'}, {id: 'f2', floor: 'F2'}, {id: 'f3', floor: 'F3'}];
this.requestsObj = [{ shift: null, floor: null, type: {} }, { shift: null, floor: null, type: {} }, { shift: null, floor: null, type: {} }];
模板
<div class="card whiteBckg" ng-repeat="(key, value) in $ctrl.requestsObj" ng-if="true">
<div class="cardHeaderDiv">
<h4>{{key}}
<span>X</span>
</h4>
</div>
<div class="cardBodyDiv">
<md-select ng-model="value.shift" placeholder="Select Shift" required md-no-asterisk="false">
<md-option ng-value="tm.shiftid" ng-repeat="tm in $ctrl.shifts">{{ tm.shift }}</md-option>
</md-select>
<md-select ng-model="value.floor" placeholder="Select Floor" required md-no-asterisk="false">
<md-option ng-value="fl.id" ng-repeat="fl in $ctrl.floors">{{ fl.floor }}</md-option>
</md-select>
<div ng-repeat="(a, b) in value.type" class="chip">
<i class="fa fa-clock-o"></i>{{ getTotal(key, k, a) }} {{a}}
</div>
</div>
<div class="cardFooterDiv">
<h4>Add more shifts for this day</h4>
</div>
</div>
屏幕截图