7

How to link a checkbox list using Angular and get all the value selected from th...

 3 years ago
source link: https://www.codesd.com/item/how-to-link-a-checkbox-list-using-angular-and-get-all-the-value-selected-from-the-check-box-using-the-ng-reapet-method.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to link a checkbox list using Angular and get all the value selected from the check box using the ng-reapet method

advertisements

How to bind a checkbox list using AngularJS and get all selected value from the checkbox using ng-reapet method?

I am try to get the value of the selected check box in the angular controller.

View

<ul class="to_do">
    <li ng-repeat="form in ManagementScreenModel.Forms">
        <!--<input type="checkbox" ng-model="RoleData.formUrl" value="{{form.Value}}" id="{{form.Value}}">-->

        <input type="checkbox"
               ng-model="RoleData.selectedForms"
               data-checklist-model="RoleData.ManagementScreenModel.Forms"
               data-checklist-value="{{form.Value}}"
               id="{{form.Value}}">

        {{form.Text}}
    </li>
</ul>

Controller

$scope.SetUserpermision = function() {
    Get(
        "/Home/GetAvailableForms",
        null,
        function(result) {},
        function(result) {
            userforms = result;
            //$scope.GetUserForms = json.parse(result);
        },
        null
    );

    Post(
        "/ManagementScreen/SetAccess",
        $scope.RoleData.userforms,
        function OnError(jqXHR, testStatus, errorThrown) {
            // display error here
        },
        function (result) {
            var response = JSON.parse(result);
            if (response != null && response.StatusCode === 200) {
                //alert("User email change successfully");
            }
        },
        null
    );
}


Have a boolean variable in ManagementScreenModel.Forms (like 'checked') and after submitting the form check variable the entry is checked or not.

<md-checkbox ng-model="user.checked" aria-label="Checkbox 1"></md-checkbox>

    angular.forEach($scope.users, function(user, i) {
     if(user.checked === true){
//store in an array
}
});

Demo https://plnkr.co/edit/MTyDSrXCZXlJXVHcyrCV?p=preview


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK