Search code examples
javascriptangularjsangularjs-ng-repeatrenderangular-ngmodel

Angular JS Rendering <md-checkbox> with array variables ng-repeat


I am using Angular JS and my md-check does not work with Array from Controller. Bellows are the code.

Front End

<md-content flex="13" class="week-day-time bg-white"  ng-repeat="weekday in staff.work_plan" layout-padding>
   <md-checkbox ng-model="weekday.status"><span class="text-uppercase text-bold">{{ weekday.day }}</span> 
   </md-checkbox>
   <fieldset class="demo-fieldset" >
   <legend class="demo-legend"><?php echo lang('working_hours') ?></legend>
        <md-input-container>
            <label><?php echo lang('start') ?></label>
            <input str-to-time="" ng-model="weekday.start" type="time">
   </md-input-container>

JS

$http.get(BASE_URL + 'api/staff_detail/' + STAFFID).then(function (StaffDetail) {
        $scope.staff = StaffDetail.data;
        $scope.UpdateWorkPlan = function () {
            var dataObj = $.param({
                work_plan: $scope.staff.work_plan
            });
            var config = {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                }
            };

Other variables with weekday.day and working hours, weekday.start does work but weekday.status does not working with md-checkbox.

Hoping your help.

Regards


Solution

  • Value of ng-model on md-checkbox should be Boolean. Make sure your data isn’t a string “true” or “false”. Check your data to make sure what you have.