我在我的html中有2選擇指令,並希望當複選框被選中時將它們重新命名......我怎麼辦?我已將ng-model="ckecked"
添加到input type="ckeckbox"
和ng-disabled
指令,但它們不起作用。當檢查複選框時禁用選擇框指令
**year Drop Directive.js**
(function() {
"use strict";
angular.module('components.others').directive('yearDrop',function(){
function getYears(offset, range){
var currentYear = new Date().getFullYear();
var years = [];
for (var i = 0; i < range + 1; i++){
var yearStr = ''+ (currentYear + offset - i);
var newYear = {
'label': yearStr,
'value': yearStr
};
years.push(newYear);
}
return years;
}
return {
restrict: 'E',
scope:{
year:'=year'
},
link: function(scope,element,attrs){
scope.years = getYears(+attrs.offset, +attrs.range);
},
template: '<select class="form-control" ng-model="year" ng- options="option.label for option in years track by option.value"><option value=""> Select Year</option></select>'
}
});
})();
HTML
<div class="row" ng-init="checked=true">
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="_500">End date</label>
<year-drop year="employment.endDateYear" offset="0" range="60"></year-drop>
</div>
</div>
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="_500"> </label>
<month-drop month="employment.endDateMonth"></month-drop>
</div>
</div>
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="block _500"> </label>
<label class="block m-t-sm md-check">
<input type="checkbox"><i class="blue" ng-model="checked"></i>Current
</label>
</div>
</div>
</div>
您的意思是ng-model =「checked」和input type =「checkbox」,是嗎? – ralphearle