Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在默认情况下将复选框设置为true_Html_Angularjs - Fatal编程技术网

Html 如何在默认情况下将复选框设置为true

Html 如何在默认情况下将复选框设置为true,html,angularjs,Html,Angularjs,html: <div class="col-lg-2 col-sm-2 col-md-2 col-xs-2"> <input type="checkbox" ng-model="selectedRecord.extendLiveData" > </div> $scope.selectedRecord.extendLiveData = true; 希望将复选框默认设置为true。怎样?如果未选中ng,ng更改您可以通过以下方式通过HTML进行更改:

html:

<div class="col-lg-2 col-sm-2 col-md-2 col-xs-2">
     <input type="checkbox" ng-model="selectedRecord.extendLiveData" >
</div>
$scope.selectedRecord.extendLiveData = true;

希望将复选框默认设置为true。怎样?如果未选中
ng
ng更改

您可以通过以下方式通过HTML进行更改:

$scope.selectedRecord.extendLiveData = true;
<input type="checkbox" ng-model="selectedRecord.extendLiveData" checked>

您可以通过HTML这样做:

$scope.selectedRecord.extendLiveData = true;
<input type="checkbox" ng-model="selectedRecord.extendLiveData" checked>

只需初始化
$scope。selectedRecord
作为对象

$scope.selectedRecord.extendLiveData = true;
$scope.selectedRecord = {};
$scope.selectedRecord.extendLiveData = true;
角度模块(“应用程序”,[]) .controller(“ctrl”,函数($scope){ $scope.selectedRecord={}; $scope.selectedRecord.extendLiveData=true; })

框值{{selectedRecord.extendLiveData}

只需初始化
$scope。selectedRecord
作为对象

$scope.selectedRecord.extendLiveData = true;
$scope.selectedRecord = {};
$scope.selectedRecord.extendLiveData = true;
角度模块(“应用程序”,[]) .controller(“ctrl”,函数($scope){ $scope.selectedRecord={}; $scope.selectedRecord.extendLiveData=true; })

框值{{selectedRecord.extendLiveData}
只需在输入标记中输入“checked”。比如:

$scope.selectedRecord.extendLiveData = true;
<input type="checkbox" ng-model="selectedRecord.extendLiveData" checked>

只需在输入标记中输入“checked”。比如:

$scope.selectedRecord.extendLiveData = true;
<input type="checkbox" ng-model="selectedRecord.extendLiveData" checked>

创建
selectedRecord
对象,该对象具有
extendedlivedata
字段的真值

$scope.selectedRecord.extendLiveData = true;
var-app=angular.module('myApp',[]);
app.controller('chkboxCtrl',函数($scope,$http){
$scope.selectedRecord={extendLiveData:true}
});

默认选中复选框

创建
selectedRecord
对象,该对象具有
extendedlivedata
字段的真值

$scope.selectedRecord.extendLiveData = true;
var-app=angular.module('myApp',[]);
app.controller('chkboxCtrl',函数($scope,$http){
$scope.selectedRecord={extendLiveData:true}
});

默认选中复选框

您的复选框是否在ng repeat内?您的复选框是否在ng repeat内?