checklist-model icon indicating copy to clipboard operation
checklist-model copied to clipboard

checklist-model not working when ng-if is used on the same element

Open sebastian-zarzycki opened this issue 9 years ago • 10 comments

HTML

<div ng-repeat="obj in objects">
<input type="checkbox" ng-if="form.condition" checklist-model="form.model" checklist-value="obj.id" > {{ obj.title }}
</div>

JS

$scope.form = {
    condition: true,
    model: null
};

$scope.objects = [ {id:1, title: '1'}, {id:2, title:'2'},  {id:3, title:'3'} ];

This makes checklist-model attr disappear when looking in generates source, and model changes are not filled in properly. It can be fixed by putting the ng-if in the parent element. Apparently something with scope/linking isn't clicking?

sebastian-zarzycki avatar Dec 03 '15 21:12 sebastian-zarzycki

Could you please prepare a JSFiddle or Plunker example? Thanks!

beradrian avatar Dec 04 '15 08:12 beradrian

Sorry. I've provided all the information you need.

sebastian-zarzycki avatar Dec 04 '15 09:12 sebastian-zarzycki

If you prepare a test case, a JSFiddle or Plunker example, it would help in solving the issue and find a fix much faster. Otherwise, it could take a while until I do this myself. Thank you.

beradrian avatar Dec 04 '15 10:12 beradrian

I created a jsfiddle and I can reproduce the issue: http://jsfiddle.net/beradrian/3gwomn97/. I will work on it.

beradrian avatar Dec 10 '15 17:12 beradrian

I've reproduced the same issue with ng-switch

michaelryancaputo avatar Mar 03 '16 18:03 michaelryancaputo

Same issue here. My solution was wrap the input element with a div, and use ng-if in the div

leskeg-zz avatar Mar 05 '16 14:03 leskeg-zz

Please fix this bug!

nminhduc avatar Sep 30 '16 09:09 nminhduc

Any news on this issue?

Bbbrinks avatar Nov 03 '16 13:11 Bbbrinks

As told by @leskeg, the issue gets resolved by moving ng-if condition to a wrapper. can be verified at this: http://jsfiddle.net/3Lbx453u

sajidali avatar Nov 08 '16 10:11 sajidali

@sebastian-zarzycki u can solve this problem by use checklist-model="$parent.form.model" instead of checklist-model="form.model";because when u use "ng-repeat" a new $scope is created and it can't get the current form obj .

HAOGRE avatar Dec 02 '16 10:12 HAOGRE