Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sebastian-zarzycki opened this issue Dec 3, 2015 · 10 comments
Labels

Comments

@sebastian-zarzycki
Copy link

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?

@beradrian
Copy link
Collaborator

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

@sebastian-zarzycki
Copy link
Author

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

@beradrian
Copy link
Collaborator

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
Copy link
Collaborator

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

@michaelryancaputo
Copy link

I've reproduced the same issue with ng-switch

@leskeg-zz
Copy link

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

@nminhduc
Copy link

Please fix this bug!

@Bbbrinks
Copy link

Bbbrinks commented Nov 3, 2016

Any news on this issue?

@sajidali
Copy link

sajidali commented Nov 8, 2016

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

@HAOGRE
Copy link

HAOGRE commented Dec 2, 2016

@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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants