我是新來angularjs.I有一種形式,我有多行單選按鈕和textboxes.But我無法獲得單選按鈕在controller.My代碼的價值:不能獲得單選按鈕值到控制器
HTML:
<tr ng-repeat="consentinfo in listofdata" ng-disabled="abc">
<td><input type="text" class="form-control" ng-model="consentinfo.consentType"></input></td>
<td>
<input id="radio-1{{$index}}" class="radio-custom" name="radio-group{{$index}}" ng-value="consentinfo.option1" ng-model="radio1" type="radio" ng-click="radio()">
<label for="radio-1{{$index}}" class="radio-custom-label">Yes</label>
<input id="radio-2{{$index}}" class="radio-custom" name="radio-group{{$index}}" ng-value="consentinfo.option2" ng-model="radio2" type="radio" ng-click="radio()">
<label for="radio-2{{$index}}" class="radio-custom-label">No</label>
</td>
<td>
<input type="text" ng-model="consentinfo.expDate" class="form-control date" readonly>
</td>
<td>
<input type="text" ng-model="consentinfo.submittedDate" class="form-control date" readonly>
</td>
<td><input type="text" value="" class="form-control" ng-model="consentinfo.shortDescription"></td>
<td><input type="text" value="" class="form-control" ng-model="consentinfo.longDescription"></td>
</tr>
.js文件:
var consentManagerApp = angular.module('consentManager', []);
consentManagerApp.controller('dataOwnerController', ['$scope', function($scope) {
$scope.listofdata = [{
"consentType": "Do you consent for us to use your private data for KF Searches",
"expDate": "14-12-2017",
"submittedDate": "24-04-2017",
"option1": "true",
"option2": "false",
"status": true,
},
{
"consentType": "Consent to be contacted",
"expDate": "10-10-2017",
"submittedDate": "12-02-2017",
"option1": "true",
"option2": "false",
"status": true,
},
{
"consentType": "Consent to be solicited",
"expDate": "06-08-2017",
"submittedDate": "02-12-2017",
"option1": "true",
"option2": "false",
"status": true,
},
{
"consentType": "Consent to participate in Trend studies",
"expDate": "10-11-2017",
"submittedDate": "12-02-2017",
"option1": "true",
"option2": "false",
"status": true,
},
{
"consentType": "Consent to participate in recruiting practice",
"expDate": "10-10-2017",
"submittedDate": "12-02-2017",
"option1": "true",
"option2": "false",
"status": true,
}
];
$scope.submitConsent = function() {
alert('CTY=' + $scope.choices[0] + 'O2=' + $scope.choices[1]);
alert('Listdata=' + $scope.radio1 + " " + "O2=" + $scope.radio2);
}]);
consentManagerApp.filter('unsafe', function($sce) {
return $sce.trustAsHtml;
});
任何一個可以指導我如何我就能拿到。我需要堅持它在數據庫中的值。
問候, Prabhash
你能提供一個'小提琴嗎? –
請參閱下面的答案。一定要勾選它正確,如果這可以幫助你 –