I have the following code in my application:
<input type="checkbox" ng-checked="vm.eduToEdit.test" />
{{vm.eduToEdit.test}}
<input type="checkbox" ng-model="vm.eduToEdit.test">
the value vm.eduToEdit.test is diplaying true or false, but no matter what it returns the checkboes in either input above are not checked. I'm not sure what i'm missing, i thought i shouldn't use ng-model so then I tried ng-checked, but neither has worked so far.
EDIT: I tried the below, but same result:
<input type="checkbox" ng-checked="vm.eduToEdit.test" /> -
<input type="checkbox" ng-checked="checking" /> -
{{vm.eduToEdit.test}}
{{checking}}
In my controller i have:
vm.eduToEdit.test = true;
$scope.checking = true;
When I view the page, true is written out, but i never see it checked.
Below is my controller:
(function () {
'use strict';
myModule.controller('EducationController', ["$scope", "bootstrappedData", EducationController]);
function EducationController($scope, bootstrappedData) {
var vm = this;
vm.shoppingCart = bootstrappedData.shoppingCart;
vm.eduToEdit = {};
vm.EditEducation = function (applicantEducationId, educationTypeId) {
var owl = $(".owl-carousel");
var eduFound = $.grep(this.shoppingCart, function (h) {
return h.ApplicantEducationId === applicantEducationId;
});
vm.eduToEdit = eduFound[0];
vm.eduToEdit.formattedAttendEnd = vm.ConvertToDate(vm.eduToEdit.AttendEnd);
vm.eduToEdit.formattedAttendStart = vm.ConvertToDate(vm.eduToEdit.AttendStart);
vm.eduToEdit.formattedGraduationDate = vm.ConvertToDate(vm.eduToEdit.GraduationDate);
vm.eduToEdit.test = true;
$scope.checking = true;
switch (educationTypeId) {
case 1:
case 2:
case 3:
case 4:
owl.trigger('to.owl.carousel', [1, 50]);
break;
case 5:
owl.trigger('to.owl.carousel', [3, 50]);
break;
case 6:
owl.trigger('to.owl.carousel', [2, 50]);
break;
case 7:
owl.trigger('to.owl.carousel', [4, 50]);
break;
case 9:
owl.trigger('to.owl.carousel', [5, 50]);
break;
}
};
vm.ConvertToDate = function (jsonDateToConvert) {
if (jsonDateToConvert == null)
return "";
var value = new Date
(
parseInt(jsonDateToConvert.replace(/(^.*\()|([+-].*$)/g, ''))
);
return value.getMonth() + 1 + "/" + value.getDate() + "/" + value.getFullYear();
}
}
})();
ng-click="vm.eduToEdit.test = !vm.eduToEdit.test"instead ofng-checked="vm.eduToEdit.test"will work