0

I have one table datas, if i click first row i am getting that first row data,

This is my json data im getting:

editClientdata:

{
firstname:"Sameer"
isActive:true
lastname:"Mohamed"
password:"$2a$10$i5Or69.1qRKN8.PSzybkc.2D2fPfGJCf9gwfjpE1JAF4rFUmpbC8i"
role:"client"
username:"ganesh"
}

If i click edit button i have small modal in this if my isActive object key is true i want my Active radio button to be checked:

My jade code:

input#Active(type='radio', value='1', ng-model='editClientData.isActive') Active

input#Inactive(type='radio', value='0', ng-model='editClientData.isActive') Block

My complete jade code with table:

table.table
                tr(style='font-size:14px;')
                  th(style='display : none;') S.no
                  th User Name
                  th First Name
                  th Role
                  th Status
                  th Operations
                tr(style='font-size:14px;' ng-repeat='admin in admins | filter:test' ng-if="admin.role === 'client'")
                    td(style='display : none;') {{$index+1}}
                    td {{admin.username}}
                    td {{admin.firstname}}
                    td {{admin.role}}
                    td {{true == admin.isActive ? 'Active' : 'Blocked' }}
                    td 
                     a(ng-click='editClient(admins[$index])',data-toggle='modal', data-target='#editClientModal')
                      i.fa.fa-pencil    
                     #editClientModal.modal.fade(tabindex='-1', role='dialog', aria-labelledby='myModalLabel', aria-hidden='true')
                       .modal-dialog(role='document')
                        .modal-content
                          .modal-header
                            button.modal-close(type='button', data-dismiss='modal', aria-label='Close')
                              i.font-icon-close-2
                            h4#myModalLabel.modal-title Edit Client
                          .modal-body
                            .form-group
                              label Username
                              input.form-control(type='text', placeholder='',ng-model='editClientData.username')
                            .form-group
                              label Firstname
                              input.form-control(type='text', placeholder='',ng-model='editClientData.firstname')
                            .form-group
                              label Lastname
                              input.form-control(type='text', placeholder='',ng-model='editClientData.lastname')
                            .form-group
                              span.control-label Status
                              span.text-danger  *
                              |    
                              input#Active(type='radio', value='1', ng-model='editClientData.isActive')
                              span(for='Active')  Active
                              |    
                              input#Inactive(type='radio', value='0', ng-model='editClientData.isActive')
                              span(for='Inactive')  Block

My controller.js:

// get admins
            $http({
                method: 'GET',
                url: '/api/getadmins'
            }).then(function (response) {
                $scope.admins = response.data;
            }, function (response) {
                window.location.href = '/';
            });
Mohamed Sameer
  • 2,998
  • 3
  • 22
  • 51

1 Answers1

-1

Try the following:

input#Something(type='radio', ng-change='editClientData.isActive = !editClientData.isActive', ng-model='editClientData.isActive')
Basile Perrenoud
  • 4,039
  • 3
  • 29
  • 52