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

ng-model with ng-if different scope #2137

Open
moparlakci opened this issue Apr 12, 2020 · 0 comments
Open

ng-model with ng-if different scope #2137

moparlakci opened this issue Apr 12, 2020 · 0 comments

Comments

@moparlakci
Copy link

Just to let you know if you wrap your ng-file-upload with an ng-if it will create a child scope and the ng-model binding will not work.

It will work but it will only change the model in the child scope and the 'parent' the actual scope will not know about it.

Use ng-show instead..

$scope.files = null;

<div ng-if="isReady">
       <label>Choose file</label> 
       <input type="file" ngf-select ng-model="files" ngf-multiple="true" ngf-pattern="'*/*'" ngf-accept="'*/*'" ngf-max-size="20MB" />
</div> 
console.log($scope.files);
null
<div ng-show="isReady">
       <label>Choose file</label> 
       <input type="file" ngf-select ng-model="files" ngf-multiple="true" ngf-pattern="'*/*'" ngf-accept="'*/*'" ngf-max-size="20MB" />
</div> 
console.log($scope.files);
[{}, {}, {}}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant