Reputation: 2175
Hi I am developing web application in angularjs. I have file upload module. I have below html code.
<div ng-if="FilepathDL == ''">
<input type="file" file-model="attachmentDL" name="attachmentDL" class="form-control" />
</div>
<div ng-if="FilepathDL != ''">
<a ng-href="" ng-click="openfile(FilepathDL)">{{ 'View File' | translate }}</a>
</div>
On page load i am not assigning any values to FilepathDL so first ng-if statement should render. This is happening. After uploading file when submitting the form $scope.attachmentID is ""
If i remove ng-if and directly put then i am getting file. May i know what is happening if i put my file control inside ng-if? Any help would be appreciated. Thank you.
Upvotes: 1
Views: 731
Reputation: 6620
ng-if
creates a child scope. So the file-model is not directly attached to the controllers scope.
You can avoid the problem by any one of the following methods
ng-show
instead of ng-if
For more reference : https://github.com/angular/angular.js/wiki/Understanding-Scopes
Upvotes: 1