javascript - Angular UI Switch not retaining enabled when enabled

one text

i'm a newbie here, hope you could help me with my problem, i am having trouble with retaining the enabled status of my angular ui switch... whenever i refresh the page, it reverts back to disabled . but when i check the database, i could it has updated the value and the selected setting name for the selected ui switch. i want to retain the enabled status of my angular ui switch whenever i enabled it

here is my javascript

(function () {
    'use strict';

    angular.module('mainApp')
        .controller('AdminSettingsController', AdminSettingsController);

    function AdminSettingsController(
         $scope
         ,$location
         ,AdminSettingsService
         ,$routeParams
    ) {

        $scope.updateSettings = updateSettings;
        $scope.getList = getList;

        $scope.companyId = $routeParams.companyId;

        function updateSettings(key, newStatus) {

            AdminSettingsService.saveSetting(newStatus, key, $scope.companyId).then(function (responseObj) {
                let data = responseObj.data;
                console.log(data.settings)
                let success = data.success;

                $scope.settings = data.settings;

                return data.settings;
            });
        }

          function getList(key){

            AdminSettingsService.getSetting(key).then(function (response) {
                let data = response.data;
                console.log('hardyharhar');
                let success = data.success
            });
        }
    }
})();

here is my html

<side-nav active-tab="'admin'"></side-nav>
<head-bar></head-bar>

<div class="br-mainpanel">
    <div class="br-pageheader pd-y-15 pd-l-20">
        <nav class="breadcrumb pd-0 mg-0 tx-12">
            <a class="breadcrumb-item" href="#!/home">Dashboard</a>
            <span class="breadcrumb-item active">Admin Settings</span>
        </nav>
    </div>

    <div class="pd-x-5 pd-sm-x-30 pd-t-20 pd-sm-t-2">

        <div class="d-flex align-items-center ">
            <i class="icon ion-settings tx-54" style="margin-right: 1px;"></i>
            <div class="mg-l-20">
                <h4 class="tx-18 tx-gray-800 mg-b-5" style="size: 50px; font-weight: bold">Admin Settings</h4>
                <span class="mg-b-0">Settings for company.</span>
            </div>
            <div id="ch5" class="ht-60 tr-y-1"></div>
        </div>
    </div>

    <div class="br-pagebody">
        <div class="br-section-wrapper">
            <div class="br-pagebody pd-x-20 pd-sm-x-30">
                <div class="card bd-0 shadow-base">
                    <div class="table-responsive">
                            <table class="table table-striped table-bordered mg-b-0">
                                <thead>
                                    <th style="width: 10%" class="text-center">Action</th>
                                    <th style="width: 40%" class="text-center">Settings</th>
                                    <th style="width: 10%" class="text-center">Status</th>
                                </thead>
                                <tbody>
                                <tr class="text-center">
                                    <td>
                                        <switch ng-change="updateSettings('isReimbursementEnabled', reimbursementStatus)" id="state" name="state" ng-model="reimbursementStatus" class="blue"></switch>
                                    </td>
                                    <td class="text-left">
                                        <h4>Reimbursement</h4>
                                        <p>Allows processor to access reimbursement {{ reimbursementStatus }}.</p>
                                    </td>
                                    <td>
                                        <h4> <span class= "{{ reimbursementStatus  ? 'badge badge-pill badge-success' : 'badge badge-pill badge-secondary' }}">
                                           {{ reimbursementStatus ? "Enabled" : "Disabled"}}
                                            </span>
                                        </h4>
                                    </td>
                                </tr>
                                <tr class="text-center">
                                    <td>
                                        <switch ng-change="updateSettings('isReportsEnabled', reportsEnabled)" id="state" name="state"  ng-model="reportsEnabled" class="blue"></switch>
                                    </td>
                                    <td class="text-left">
                                        <h4 class="">Reports</h4>
                                        <p>Allows processor to access reports.</p>
                                    </td>
                                    <td>
                                        <h4> <span class="{{ reportsEnabled ? 'badge badge-pill badge-success' : 'badge badge-pill badge-secondary' }}" >
                                            {{ reportsEnabled ? "Enabled" : "Disabled" }}
                                            </span>
                                        </h4>
                                    </td>
                                </tr>
                                <tr class="text-center">
                                    <td>
                                        <switch ng-change="updateSettings('isAccountsEnabled', accountStatus)" id="state" name="state" ng-model="accountStatus" class="blue"></switch>
                                    </td>
                                    <td class="text-left">
                                        <h4 class="">Accounts</h4>
                                        <p>List of company accounts.</p>
                                    </td>
                                    <td>
                                        <h4><span class="{{ accountStatus ? 'badge badge-pill badge-success' : 'badge badge-pill badge-secondary' }}" >
                                            {{ accountStatus ? "Enabled" : "Disabled" }}
                                            </span>
                                        </h4>
                                    </td>
                                </tr>
                                <tr class="text-center">
                                    <td>
                                        <switch ng-change="updateSettings('isReimbursementRequestLimitEnabled', requestStatus)" id="state" name="state" ng-model="requestStatus" class="blue"></switch>
                                    </td>
                                    <td class="text-left">
                                        <h4 class="">Reimbursement Request Limit</h4>
                                        <p>Sets the reimbursement request limit per year.</p>
                                    </td>
                                    <td>
                                        <h4><span class="{{ requestStatus ? 'badge badge-pill badge-success' : 'badge badge-pill badge-secondary' }}">
                                            {{ requestStatus ? "Enabled" : "Disabled" }}
                                            </span>
                                        </h4>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                 </div>
               </div>
          <foot-bar></foot-bar>
         </div>
        </div>

and here is my api controller


namespace App\Http\Controllers\Api;

use App\Criteria\LimitOffsetCriteria;
use App\Http\Controllers\Controller;
use App\Models\AdminSettings;
use App\Models\AccountSettings;
use App\Models\Account;
use App\Repositories\AccountRepositoryEloquent;
use App\Repositories\AdminSettingsRepositoryEloquent;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class AdminSettingApiController extends Controller
{

    private $adminSettingsRepository;
    private $accountRepository;

    public function __construct(
        AdminSettingsRepositoryEloquent $adminSettingsRepo
        ,AccountRepositoryEloquent $accountRepo
    )
    {
        $this->adminSettingsRepository = $adminSettingsRepo;
        $this->accountRepository = $accountRepo;

    }

    public function saveSetting(Request $request) {
        $newStatus = $request->input('newStatus');
        $key = $request->input('key');
        $companyId = $request->input('companyId');


        $result = array(
            'success' => false
        );

        $keyExist = $this->adminSettingsRepository->findByField('setting_name', $key)->first();

        log::debug('thisisKeyExist.......................'.json_encode($keyExist));

        $newStatusData = [
            'setting_name' => $key,
            'status' => $newStatus,
            'company_id' => $companyId
        ];

        try {
            DB::beginTransaction();

            if (!$keyExist) {
                $newStatus = AdminSettings::create($newStatusData);
            }
            else {
                $updateQuery = AdminSettings::where('setting_name', '=', $key);
                              $updateQuery->update($newStatusData);
                }
             $result['success'] = true;
             $result['settings'] = $newStatusData;

             DB::commit();

          } catch (Exception $e) {
            Log::error($e);
            $result['success'] = false;
            $result['messages'] = ['Server has encountered an unexpected error.'];
          }
        return $result;
         }

         public function  list(Request $request){

           $key = $request->input('key');

              $result = array(
                'success' => false
               );

              $keySetting = $this->adminSettingsRepository->findByField('setting_name', $key)->first();

              $keyList = [];
              try {
                    DB::beginTransaction();

                    $keyList = $this->adminSettingsRepository::where('status', '=', 1, 'setting_name')->get();
                    Log::debug('thisIsPrimarykey...................'.json_encode($keyList));

                    $result['key'] = $key;
                    $result['success'] = true;

                    DB::commit();
                  }
              catch (\Exception $e){
                Log::error($e);
                  $result['success'] = false;
                 }
             }
        }

hope you could help me thanks a lot! :)

Source