0

I am having radio buttons in angularjs. I am using ICheck directive for the setting the styles for the checkbox and radio button. The radio button is not checked on Edit of particular row. This is Icheck directive:

    adminApp.directive('icheck', ['$timeout', '$parse', function ($timeout, $parse) {
     return {
      link: function($scope, element, $attrs) {
        return $timeout(function() {
          var ngModelGetter, value;
          ngModelGetter = $parse($attrs['ngModel']);
          value = $parse($attrs['ngValue'])($scope);
          return $(element).iCheck({
            checkboxClass: 'icheckbox_minimal',
            radioClass: 'iradio_minimal-blue',
            checkboxClass: 'icheckbox_minimal-blue',
            increaseArea: '20%'
          }).on('ifChanged', function(event) {
            if ($(element).attr('type') === 'checkbox' && $attrs['ngModel']) {
              $scope.$apply(function() {
                return ngModelGetter.assign($scope, event.target.checked);
              });
            }
            if ($(element).attr('type') === 'radio' && $attrs['ngModel']) {
              return $scope.$apply(function() {
                return ngModelGetter.assign($scope, value);
              });
            }
          });
        });
      }
    };
}])

My html code for radio button is

<label class="radio-inline"><input type="radio" name="blogColumnType"  icheck ng-model="blog.createBlog.BlogColumnTypeId" ng-value="1">&nbsp;&nbsp;Single Column</label>
<label class="radio-inline"><input type="radio" name="blogColumnType" icheck ng-model="blog.createBlog.BlogColumnTypeId" ng-value="2">&nbsp;&nbsp;Double column</label>&nbsp;&nbsp;

blog.createBlog.BlogColumnTypeId is my scope variable.

Kindly help me to fix this. Thanks in advance.

Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
  • when i try with above code its giving me error at return $(element).iCheck.....as $ is undef....i tried with adding jquery then i got TypeError: $(...).iCheck is not a function – Sa E Chowdary Dec 15 '16 at 11:06
  • Possible duplicate of [Integration of Angular and JQuery.iCheck by using a directive is not working](http://stackoverflow.com/questions/19346523/integration-of-angular-and-jquery-icheck-by-using-a-directive-is-not-working) – Ramesh Rajendran Dec 15 '16 at 11:16

0 Answers0