这里我使用了带有angularjs的复选框。如果状态为真,它可以触发; 那就是$ scope.seededDataAdhoc == 1。如果$ scope.seededDataAdhoc == 0则应禁用它。它在第一次加载时禁用。但是当我从本地存储加载数据时,无法禁用。
同样地, ng-click也无法正常工作。我在这里呆了很长时间。 任何人都可以请你帮忙。
Html代码:
<label class="chkbox-holder" for="seededDatasAdhoc" ng-class="{'chck-active':seededDataAdhoc==1,'cursorprop':true}" ng-disabled="recurreadOnlyLoad==0" ng-click="seededDataAdhoc != seededDataAdhoc;Recurring(seededDataAdhoc)">
<input type="checkbox" class="channelclass" name="seededDatasAdhoc" id="seededDatasAdhoc" ng-model="seededDataAdhoc" ng-checked="seededDataAdhoc==1" ng-disabled="recurreadOnlyLoad==0" parse-int="" ng-true-value="1" ng-false-value="0">
<label for="seededDatasAdhoc"></label>Recurs Every Month</label>
在控制器中,
if($localStorage.recurryassign==true)
{
for(var i=0;i<data.ApplicationSettingsList.applicationSettings.length;i++)
{
if(data.ApplicationSettingsList.applicationSettings[i].name == "recurring")
{
$scope.seededDataAdhoc= data.ApplicationSettingsList.applicationSettings[i].userEditable;
if($scope.seededDataAdhoc==0)
{
$scope.recurreadOnly=0;
$scope.recurreadOnlyLoad=0;
$scope.recurreadOnlySave=false;
}
else
{
$scope.recurreadOnly=1;
$scope.recurreadOnlyLoad=1;
$scope.recurreadOnlySave=true;
}
}
}
}
else
{
$scope.seededDataAdhoc=$localStorage.seededDataAdhoc;
if($scope.seededDataAdhoc==0)
{
$scope.recurreadOnly=0;
//cant able to assign this scope to html(in ngdisabled)
$scope.recurreadOnlyLoad=0;
$scope.recurreadOnlySave=false;
}
else
{
$scope.recurreadOnly=1;
$scope.recurreadOnlyLoad=1;
$scope.recurreadOnlySave=true;
}
}