How to assign single variable for multiple file retrieve and showing in view file

8 views
Skip to first unread message

dev...@ecentrichr.com

unread,
Mar 20, 2018, 10:39:12 AM3/20/18
to Angular and AngularJS discussion
Hello,
We have a situation in one of our project that in the view the same directives are using for showing file and for upload file also. We need to show multiple files based on different pricing mode. So, is there any way that we can show different files for different pricing mode based on the single variable which is used in view as a directives and scope variable in controller.

Right now to show the files for different pricing mode we need the separate variable otherwise the data in one pricing mode is showing in another pricing mode. It will be better if we can use the single variable.

View file sample
======================
Pricing mode 1:

<div class="hand-cursor previews" ng-click="download(empanelFile1.url)">
<span tooltip=  "{{empanelFile1.url | nameFilterTooltip}}">{{empanelFile1.url | nameFilter}}</span>
</div>
<div style="display:inline-block"  ng-class="{'app-container-blur':panUploader1}" data-ng-hide="empanelFile1">
<div class="">
<div file-uploader set-url="setPanFileUrl1(url)"  plcholder={{panFileName1}}></div>
</div>
</div>

Pricing mode 2:

<div class="hand-cursor previews" ng-click="download(empanelFile2.url)">
<span tooltip=  "{{empanelFile2.url | nameFilterTooltip}}">{{empanelFile2.url | nameFilter}}</span>
</div>
<div style="display:inline-block"  ng-class="{'app-container-blur':panUploader1}" data-ng-hide="empanelFile2">
<div class="">
<div file-uploader set-url="setPanFileUrl1(url)"  plcholder={{panFileName1}}></div>
</div>
</div>

Pricing mode 3:

<div class="hand-cursor previews" ng-click="download(empanelFile3.url)">
<span tooltip=  "{{empanelFile3.url | nameFilterTooltip}}">{{empanelFile3.url | nameFilter}}</span>
</div>
<div style="display:inline-block"  ng-class="{'app-container-blur':panUploader1}" data-ng-hide="empanelFile3">
<div class="">
<div file-uploader set-url="setPanFileUrl1(url)"  plcholder={{panFileName1}}></div>
</div>
</div>

Pricing mode 4:

<div class="hand-cursor previews" ng-click="download(empanelFile4.url)">
<span tooltip=  "{{empanelFile4.url | nameFilterTooltip}}">{{empanelFile4.url | nameFilter}}</span>
</div>
<div style="display:inline-block"  ng-class="{'app-container-blur':panUploader1}" data-ng-hide="empanelFile4">
<div class="">
<div file-uploader set-url="setPanFileUrl1(url)"  plcholder={{panFileName1}}></div>
</div>
</div>

Controller file sample
==========================
docs && docs.length > 0 ? docs[0].type==='PAN'? $scope.empanelFile1 =  docs[0] : docs[0].type==='AGREEMENT'? $scope.empanelFile2=docs[0] : docs[0].type==='RATE_CARD'? $scope.empanelFile3=docs[0] : docs[0].type==='PAN'? $scope.empanelFile4=docs[0] : $scope.empanelFile1 = false:false; // empanelDocs[0];
$scope.empanelFile2 = docs && docs.length > 1 ? docs[1] : false
$scope.empanelFile3 = docs && docs.length > 1 ? docs[2] : false
$scope.empanelFile4 = docs && docs.length > 1 ? docs[3] : false

Here we are using different variable of empanelFile as 1,2,3,4. We need to use single variable so that we can show all the files for different pricing mode. It will be better if we can get any help. Thanks in advance.


Thanks
Reply all
Reply to author
Forward
0 new messages