如何根据db(Angularjs)中存储的值检查复选框

时间:2016-11-18 12:09:24

标签: javascript html angularjs checkbox

我能够根据选中的方法向db插入值,但是我无法在从db中获取值时检查值。可以任何人给我一些帮助。谢谢。

我的模板,

Form1

我的值存储在db as,

void OpenSecondForm()
{
  Form form2 = new Form();
  form2.ShowDialog();
}

1 个答案:

答案 0 :(得分:2)

首先,在使用角度方式时,使用type = type_x; 而不是value

然后将ng-model设为ng-checked的值。

<强> ng-model

以下是已解决的片段:

&#13;
&#13;
ng-model="type" and ng-checked="type"
&#13;
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {

$scope.bussinesstypeoptions = ['Education Consultant', 'Ticket/Travel', 'Hotel/Home-Stay', 'Guardianship', 'Visa/Solicitors', 'Others']; 

$scope.object = {}
$scope.business_type = [ 
    "Education Consultant", 
    "Guardianship", 
    "Hotel/Home-Stay"
]


for(i = 0;i < $scope.business_type.length; i++)
{

$scope.object[$scope.business_type[i]] = true;
 console.log($scope.object)
  
}
});
&#13;
&#13;
&#13;

Here is a fiddle of it