2

I got a list of levels when someone clicks on the levels I need to call the method in AngularJs.When I click on the checkbox nothing is happening, but when I click on the checkbox outside the ng-repeat is working fine. This is my code.

<div class="col-md-4">
                        <label>Select Level:</label>
                        <div ng-repeat="level in vm.Levels | filter: {Workshop:true}">


                            <div class="i-checks">
                                <input type="checkbox" ng-model="level.Name" id="{{'level-'+ level.SkillId}}" icheck />
                                <label class="control-label">
                                    {{level.Name}}
                                </label>
                            </div>
                        </div>
                        <input type="checkbox" />

                    </div>

Here is my controller code:

(function () {
            'use strict';
            var controllerId = 'SeriesEditor';
            angular.module('app').controller(controllerId, ['apiFactory', "$filter", SeriesEditor]);

            function SeriesEditor(wfapi, $filter) {
                var vm = this;

                vm.Init = function () {                   
                    vm.Levels = [];                  
                }

     vm.loadLevelsForSeries = function () {

                    var mReq = new Models.services.LevelListRequest();
                    api.get(mReq)
                        .then(function (data) {
                            vm.Levels = data.Results;
                        });
                }
     }
        })();

Thanks in advance.

1
  • 1
    controller code ? Commented Oct 31, 2016 at 9:26

1 Answer 1

1

// Code goes here

angular
	.module('myApp',[])
	.run(function($rootScope){
		$rootScope.title = 'myTest Page';
	})
	.controller('testController', ['$scope', function($scope){
	  
		$scope.Levels  = [{Name:'string1',SkillId:1},{Name:'string2',SkillId:2},{Name:'string3',SkillId:3}]
		
	}])
<!DOCTYPE html>
<html data-ng-app="myApp">

<head>
  <link rel="stylesheet" href="style.css">
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
  <script src="script.js"></script>
</head>

<body data-ng-controller="testController">

  <div class="col-md-4">
    <label>Select Level:</label>
    <div ng-repeat="level in Levels">

      <div class="i-checks">
        <input type="checkbox"  id="{{'level-'+ level.SkillId}}" icheck />
        <label class="control-label">
          {{level.Name}}
        </label>
      </div>
    </div>
    <input type="checkbox" /> checkbox outside

  </div>

</body>

</html>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.