How to manage naming models in the following tableHow do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I access the $scope variable in browser's console using AngularJS?How do I return the response from an asynchronous call?How do I use $scope.$watch and $scope.$apply in AngularJS?
The term for the person/group a political party aligns themselves with to appear concerned about the general public
Hygienic footwear for prehensile feet?
California: "For quality assurance, this phone call is being recorded"
Is it possible to kill all life on Earth?
Old black and white movie: glowing black rocks slowly turn you into stone upon touch
When leasing/renting out an owned property, is there a standard ratio between monthly rent and the mortgage?
Do adult Russians normally hand-write Cyrillic as cursive or as block letters?
What does War Machine's "Canopy! Canopy!" line mean in "Avengers: Endgame"?
Credit card offering 0.5 miles for every cent rounded up. Too good to be true?
How can I grammatically understand "Wir über uns"?
Setting extra bits in a bool makes it true and false at the same time
Rotated Position of Integers
Unconventional Opposites
What is the right way to float a home lab?
Is there a practical difference between different types of Berachos?
Concise way to draw this pyramid
How to apply the "glow" effect to a rectangle with tcolorbox?
Is the decompression of compressed and encrypted data without decryption also theoretically impossible?
What's the correct term for a waitress in the Middle Ages?
pitch and volume compensations for different instruments
Is the capacitor drawn or wired wrongly?
How to provide realism without making readers think grimdark
Could a guilty Boris Johnson be used to cancel Brexit?
Does any lore text explain why the planes of Acheron, Gehenna, and Carceri are the alignment they are?
How to manage naming models in the following table
How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I access the $scope variable in browser's console using AngularJS?How do I return the response from an asynchronous call?How do I use $scope.$watch and $scope.$apply in AngularJS?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have the following table:
Lot Table View
I am using three ng-repeat to show the following response.
Response from backend overview
Detailed response from backend
The first ng-repeat is in <tbody>
. The second ng-repeat is in <tr>
. And the third one is for repeating the Lot Details, Trx Qty and Balance which is <span>
.
Following is my html code:
<table id="lotTable" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index"
ng-init="parentIndex = $index" id=parentRow$index
data-id="l.lotNo">$index
<tr ng-repeat="k in l track by $index">
<td class="indextrack" >$index+1
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="l.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">k.lotQty
</td>
<td class="cost"> k.unitPrice
</td>
<!-- Lot Details -->
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails">
<input type="hidden" class="hiddenLotDetails m-b-5"
id="lotDetails$parent.$parent.$index$parent.$index$index"
ng-model="xxx[$index]" value="c"/>
ctnchange : c<br>
$parent.$parent.$index$parent.$index$index
</span>
</td>
<!-- Transaction Quantity -->
<td class="trxQty" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index" >
<input class="trxQuantity m-b-5 text-right"
id="trx$parent.$parent.$index$parent.$index$index"
autocomplete="off"
ng-model="trx[$parent.$index][$index]"
ng-keyup="calculateBal($parent.$index,$index); checkParentCheckbox($event);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- Balance -->
<td class="balanceNew" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index">
<input ng-disabled="true" class="balanceNew m-b-5 text-right"
id="balNew$parent.$parent.$index$parent.$index$index"
type="text" style="width: 60px;"/>
<br>
</span>
</td>
</tr>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
I want to dynamically name the models of Lot Details, Trx Qty and Balance . I have named there ids using id="trx$parent.$parent.$index$parent.$index$index
for transaction quantity. I want to achieve the same for ng-model
.
I have used ng-model="trx[$parent.$index][$index]
. But I have three nested ng-repeat. This is good for two nested ng-repeat. How can it be done for three ng-repeat?
Also I have to set the $scope.trx[i][j]
values in controller.
What is the right way to name the model so that we can also set its value in controller?
javascript angularjs angularjs-scope angularjs-ng-model
add a comment |
I have the following table:
Lot Table View
I am using three ng-repeat to show the following response.
Response from backend overview
Detailed response from backend
The first ng-repeat is in <tbody>
. The second ng-repeat is in <tr>
. And the third one is for repeating the Lot Details, Trx Qty and Balance which is <span>
.
Following is my html code:
<table id="lotTable" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index"
ng-init="parentIndex = $index" id=parentRow$index
data-id="l.lotNo">$index
<tr ng-repeat="k in l track by $index">
<td class="indextrack" >$index+1
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="l.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">k.lotQty
</td>
<td class="cost"> k.unitPrice
</td>
<!-- Lot Details -->
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails">
<input type="hidden" class="hiddenLotDetails m-b-5"
id="lotDetails$parent.$parent.$index$parent.$index$index"
ng-model="xxx[$index]" value="c"/>
ctnchange : c<br>
$parent.$parent.$index$parent.$index$index
</span>
</td>
<!-- Transaction Quantity -->
<td class="trxQty" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index" >
<input class="trxQuantity m-b-5 text-right"
id="trx$parent.$parent.$index$parent.$index$index"
autocomplete="off"
ng-model="trx[$parent.$index][$index]"
ng-keyup="calculateBal($parent.$index,$index); checkParentCheckbox($event);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- Balance -->
<td class="balanceNew" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index">
<input ng-disabled="true" class="balanceNew m-b-5 text-right"
id="balNew$parent.$parent.$index$parent.$index$index"
type="text" style="width: 60px;"/>
<br>
</span>
</td>
</tr>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
I want to dynamically name the models of Lot Details, Trx Qty and Balance . I have named there ids using id="trx$parent.$parent.$index$parent.$index$index
for transaction quantity. I want to achieve the same for ng-model
.
I have used ng-model="trx[$parent.$index][$index]
. But I have three nested ng-repeat. This is good for two nested ng-repeat. How can it be done for three ng-repeat?
Also I have to set the $scope.trx[i][j]
values in controller.
What is the right way to name the model so that we can also set its value in controller?
javascript angularjs angularjs-scope angularjs-ng-model
You used the technique ofng-init="parentIndex = $index"
on the topng-repeat
but then didn't use it. Its a good technique and less error prone than$parent.$parent.whatever
.
– georgeawg
Mar 24 at 13:09
add a comment |
I have the following table:
Lot Table View
I am using three ng-repeat to show the following response.
Response from backend overview
Detailed response from backend
The first ng-repeat is in <tbody>
. The second ng-repeat is in <tr>
. And the third one is for repeating the Lot Details, Trx Qty and Balance which is <span>
.
Following is my html code:
<table id="lotTable" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index"
ng-init="parentIndex = $index" id=parentRow$index
data-id="l.lotNo">$index
<tr ng-repeat="k in l track by $index">
<td class="indextrack" >$index+1
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="l.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">k.lotQty
</td>
<td class="cost"> k.unitPrice
</td>
<!-- Lot Details -->
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails">
<input type="hidden" class="hiddenLotDetails m-b-5"
id="lotDetails$parent.$parent.$index$parent.$index$index"
ng-model="xxx[$index]" value="c"/>
ctnchange : c<br>
$parent.$parent.$index$parent.$index$index
</span>
</td>
<!-- Transaction Quantity -->
<td class="trxQty" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index" >
<input class="trxQuantity m-b-5 text-right"
id="trx$parent.$parent.$index$parent.$index$index"
autocomplete="off"
ng-model="trx[$parent.$index][$index]"
ng-keyup="calculateBal($parent.$index,$index); checkParentCheckbox($event);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- Balance -->
<td class="balanceNew" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index">
<input ng-disabled="true" class="balanceNew m-b-5 text-right"
id="balNew$parent.$parent.$index$parent.$index$index"
type="text" style="width: 60px;"/>
<br>
</span>
</td>
</tr>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
I want to dynamically name the models of Lot Details, Trx Qty and Balance . I have named there ids using id="trx$parent.$parent.$index$parent.$index$index
for transaction quantity. I want to achieve the same for ng-model
.
I have used ng-model="trx[$parent.$index][$index]
. But I have three nested ng-repeat. This is good for two nested ng-repeat. How can it be done for three ng-repeat?
Also I have to set the $scope.trx[i][j]
values in controller.
What is the right way to name the model so that we can also set its value in controller?
javascript angularjs angularjs-scope angularjs-ng-model
I have the following table:
Lot Table View
I am using three ng-repeat to show the following response.
Response from backend overview
Detailed response from backend
The first ng-repeat is in <tbody>
. The second ng-repeat is in <tr>
. And the third one is for repeating the Lot Details, Trx Qty and Balance which is <span>
.
Following is my html code:
<table id="lotTable" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index"
ng-init="parentIndex = $index" id=parentRow$index
data-id="l.lotNo">$index
<tr ng-repeat="k in l track by $index">
<td class="indextrack" >$index+1
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="l.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">k.lotQty
</td>
<td class="cost"> k.unitPrice
</td>
<!-- Lot Details -->
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails">
<input type="hidden" class="hiddenLotDetails m-b-5"
id="lotDetails$parent.$parent.$index$parent.$index$index"
ng-model="xxx[$index]" value="c"/>
ctnchange : c<br>
$parent.$parent.$index$parent.$index$index
</span>
</td>
<!-- Transaction Quantity -->
<td class="trxQty" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index" >
<input class="trxQuantity m-b-5 text-right"
id="trx$parent.$parent.$index$parent.$index$index"
autocomplete="off"
ng-model="trx[$parent.$index][$index]"
ng-keyup="calculateBal($parent.$index,$index); checkParentCheckbox($event);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- Balance -->
<td class="balanceNew" style="padding-top: 10px; padding-bottom: 10px;">
<span ng-repeat="c in k.lotDetails track by $index">
<input ng-disabled="true" class="balanceNew m-b-5 text-right"
id="balNew$parent.$parent.$index$parent.$index$index"
type="text" style="width: 60px;"/>
<br>
</span>
</td>
</tr>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
I want to dynamically name the models of Lot Details, Trx Qty and Balance . I have named there ids using id="trx$parent.$parent.$index$parent.$index$index
for transaction quantity. I want to achieve the same for ng-model
.
I have used ng-model="trx[$parent.$index][$index]
. But I have three nested ng-repeat. This is good for two nested ng-repeat. How can it be done for three ng-repeat?
Also I have to set the $scope.trx[i][j]
values in controller.
What is the right way to name the model so that we can also set its value in controller?
javascript angularjs angularjs-scope angularjs-ng-model
javascript angularjs angularjs-scope angularjs-ng-model
edited Mar 24 at 13:05
georgeawg
36.9k115471
36.9k115471
asked Mar 24 at 12:26
Abhiruchi MauryaAbhiruchi Maurya
33
33
You used the technique ofng-init="parentIndex = $index"
on the topng-repeat
but then didn't use it. Its a good technique and less error prone than$parent.$parent.whatever
.
– georgeawg
Mar 24 at 13:09
add a comment |
You used the technique ofng-init="parentIndex = $index"
on the topng-repeat
but then didn't use it. Its a good technique and less error prone than$parent.$parent.whatever
.
– georgeawg
Mar 24 at 13:09
You used the technique of
ng-init="parentIndex = $index"
on the top ng-repeat
but then didn't use it. Its a good technique and less error prone than $parent.$parent.whatever
.– georgeawg
Mar 24 at 13:09
You used the technique of
ng-init="parentIndex = $index"
on the top ng-repeat
but then didn't use it. Its a good technique and less error prone than $parent.$parent.whatever
.– georgeawg
Mar 24 at 13:09
add a comment |
1 Answer
1
active
oldest
votes
I changed my HTML code to this :
<table id="lotTable" ng-table="tableSorting" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th ng-hide="true"></th>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th ng-hide="true">Balance</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index" ng-init="parentIndex = $index" id=parentRow$index data-id="l.lotNo">
<tr ng-repeat="k in l track by $index" ng-init="lotDataChildIndex = $index">
<td header-class="'text-center'" ng-hide="true">
<div class="checkbox">
<label>
<input type="checkbox" class="checkhead" id="lotHiddenCheckboxparentIndexlotDataChildIndex">
<em class="input-helper"></em>
</label>
</div>
</td>
<td class="indextrack" >$index+1
<input type="hidden" class="hiddenalcoholPer" value="k.alcoholPer" />
<input type="hidden" class="hiddencascCode" value="k.cascCode" />
<input type="hidden" class="hiddencreditorCode" value="k.creditorCode" />
<input type="hidden" class="hiddencreditorName" value="k.creditorName" />
<input type="hidden" class="hiddencustomAmnt" value="k.customAmnt" />
<input type="hidden" class="hiddenduty" value="k.duty" />
<input type="hidden" class="hiddendutyPaid" value="k.dutyPaid" />
<input type="hidden" class="hiddenhsCode" value="k.hsCode" />
<input type="hidden" class="hiddenidUom" value="k.idUom" />
<input type="hidden" class="hiddenunitPrice" value="k.unitPrice" />
<input type="hidden" class="hiddenuomCode" value="k.uomCode" />
<input type="hidden" class="hiddenidGrnforLot" value="k.idGrn" />
<input type="hidden" class="hiddenidPhysicalLocation" value="k.idPhysicalLocation" />
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="k.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">
<input type="hidden" class="hiddenLotQty" value="k.lotQty" />k.lotQty
</td>
<td class="cost"><input type="hidden" class="hiddencost" value="k.unitPrice" /> k.unitPrice
</td>
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails" ng-init="lotDetailsIndex = $index;">
<input type="hidden" class="hiddenLotDetails m-b-5" id="lotDetailsparentIndexlotDataChildIndexlotDetailsIndex" value="c"/> ctnchange : c<br>
</span>
</td>
<td class="trxQty p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="trxQtyIndex = $index;">
<!-- lotDetailsValues Hidden field -->
<input type="hidden" class="lotDetailsValues"
id="lotDetailsValuesparentIndexlotDataChildIndextrxQtyIndex"
ng-model="lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]" ng-init="(lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]) = k.lotDetailsValues[$index];"
value="k.lotDetailsValues[$index]" />
<!-- Transaction Quantity -->
<input class="trxQuantity m-b-5 text-right"
id="trxparentIndexlotDataChildIndextrxQtyIndex"
autocomplete="off"
ng-model="trx[parentIndex + '' + lotDataChildIndex + '' + trxQtyIndex]"
ng-keyup="calculateBalanceTxtQty(parentIndex,lotDataChildIndex,trxQtyIndex);
checkParentCheckbox($event,parentIndex,lotDataChildIndex);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- BALANCE AMOUNT HIDDEN -->
<td class="balance p-t-10 p-b-10" ng-hide="true">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceIndex = $index;">
<input ng-disabled="true"
class="balanceAmt m-b-5"
id="balAmtparentIndexlotDataChildIndexbalanceIndex"
type="text"
ng-model="balAmt[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"/><br>
</span>
</td>
<!-- BALANCE NEW AFTER CALCULATION -->
<td class="balanceNew p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceNewIndex = $index;">
<input type="text" style="width: 60px;"
ng-model="balNew[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"
ng-disabled="true"
class="balanceNew m-b-5 text-right"
id="balNewparentIndexlotDataChildIndexbalanceNewIndex"/>
<br>
</span>
</td>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
<tbody>
<tr ng-if="isDataLot=='no'" class="no_records"><td colspan="8">No Record(s) found.</td></tr>
<tr ng-if="isDataLot=='yes'" >
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-right">
<strong>Total:</strong>
</td>
<td class="text-right p-r-12">(addedTrxQty > 0) ? addedTrxQty : ''</td>
<td class="text-right p-r-12">(totalTrxValBal > 0) ? totalTrxValBal : ''</td>
</tr>
</tbody>
</table>
In order to get it in controller I used the following code:
var quantity = $scope.lotDetailsValues[parentIndex+ '' +childIndex+ '' +index];
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323794%2fhow-to-manage-naming-models-in-the-following-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I changed my HTML code to this :
<table id="lotTable" ng-table="tableSorting" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th ng-hide="true"></th>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th ng-hide="true">Balance</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index" ng-init="parentIndex = $index" id=parentRow$index data-id="l.lotNo">
<tr ng-repeat="k in l track by $index" ng-init="lotDataChildIndex = $index">
<td header-class="'text-center'" ng-hide="true">
<div class="checkbox">
<label>
<input type="checkbox" class="checkhead" id="lotHiddenCheckboxparentIndexlotDataChildIndex">
<em class="input-helper"></em>
</label>
</div>
</td>
<td class="indextrack" >$index+1
<input type="hidden" class="hiddenalcoholPer" value="k.alcoholPer" />
<input type="hidden" class="hiddencascCode" value="k.cascCode" />
<input type="hidden" class="hiddencreditorCode" value="k.creditorCode" />
<input type="hidden" class="hiddencreditorName" value="k.creditorName" />
<input type="hidden" class="hiddencustomAmnt" value="k.customAmnt" />
<input type="hidden" class="hiddenduty" value="k.duty" />
<input type="hidden" class="hiddendutyPaid" value="k.dutyPaid" />
<input type="hidden" class="hiddenhsCode" value="k.hsCode" />
<input type="hidden" class="hiddenidUom" value="k.idUom" />
<input type="hidden" class="hiddenunitPrice" value="k.unitPrice" />
<input type="hidden" class="hiddenuomCode" value="k.uomCode" />
<input type="hidden" class="hiddenidGrnforLot" value="k.idGrn" />
<input type="hidden" class="hiddenidPhysicalLocation" value="k.idPhysicalLocation" />
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="k.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">
<input type="hidden" class="hiddenLotQty" value="k.lotQty" />k.lotQty
</td>
<td class="cost"><input type="hidden" class="hiddencost" value="k.unitPrice" /> k.unitPrice
</td>
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails" ng-init="lotDetailsIndex = $index;">
<input type="hidden" class="hiddenLotDetails m-b-5" id="lotDetailsparentIndexlotDataChildIndexlotDetailsIndex" value="c"/> ctnchange : c<br>
</span>
</td>
<td class="trxQty p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="trxQtyIndex = $index;">
<!-- lotDetailsValues Hidden field -->
<input type="hidden" class="lotDetailsValues"
id="lotDetailsValuesparentIndexlotDataChildIndextrxQtyIndex"
ng-model="lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]" ng-init="(lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]) = k.lotDetailsValues[$index];"
value="k.lotDetailsValues[$index]" />
<!-- Transaction Quantity -->
<input class="trxQuantity m-b-5 text-right"
id="trxparentIndexlotDataChildIndextrxQtyIndex"
autocomplete="off"
ng-model="trx[parentIndex + '' + lotDataChildIndex + '' + trxQtyIndex]"
ng-keyup="calculateBalanceTxtQty(parentIndex,lotDataChildIndex,trxQtyIndex);
checkParentCheckbox($event,parentIndex,lotDataChildIndex);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- BALANCE AMOUNT HIDDEN -->
<td class="balance p-t-10 p-b-10" ng-hide="true">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceIndex = $index;">
<input ng-disabled="true"
class="balanceAmt m-b-5"
id="balAmtparentIndexlotDataChildIndexbalanceIndex"
type="text"
ng-model="balAmt[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"/><br>
</span>
</td>
<!-- BALANCE NEW AFTER CALCULATION -->
<td class="balanceNew p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceNewIndex = $index;">
<input type="text" style="width: 60px;"
ng-model="balNew[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"
ng-disabled="true"
class="balanceNew m-b-5 text-right"
id="balNewparentIndexlotDataChildIndexbalanceNewIndex"/>
<br>
</span>
</td>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
<tbody>
<tr ng-if="isDataLot=='no'" class="no_records"><td colspan="8">No Record(s) found.</td></tr>
<tr ng-if="isDataLot=='yes'" >
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-right">
<strong>Total:</strong>
</td>
<td class="text-right p-r-12">(addedTrxQty > 0) ? addedTrxQty : ''</td>
<td class="text-right p-r-12">(totalTrxValBal > 0) ? totalTrxValBal : ''</td>
</tr>
</tbody>
</table>
In order to get it in controller I used the following code:
var quantity = $scope.lotDetailsValues[parentIndex+ '' +childIndex+ '' +index];
add a comment |
I changed my HTML code to this :
<table id="lotTable" ng-table="tableSorting" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th ng-hide="true"></th>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th ng-hide="true">Balance</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index" ng-init="parentIndex = $index" id=parentRow$index data-id="l.lotNo">
<tr ng-repeat="k in l track by $index" ng-init="lotDataChildIndex = $index">
<td header-class="'text-center'" ng-hide="true">
<div class="checkbox">
<label>
<input type="checkbox" class="checkhead" id="lotHiddenCheckboxparentIndexlotDataChildIndex">
<em class="input-helper"></em>
</label>
</div>
</td>
<td class="indextrack" >$index+1
<input type="hidden" class="hiddenalcoholPer" value="k.alcoholPer" />
<input type="hidden" class="hiddencascCode" value="k.cascCode" />
<input type="hidden" class="hiddencreditorCode" value="k.creditorCode" />
<input type="hidden" class="hiddencreditorName" value="k.creditorName" />
<input type="hidden" class="hiddencustomAmnt" value="k.customAmnt" />
<input type="hidden" class="hiddenduty" value="k.duty" />
<input type="hidden" class="hiddendutyPaid" value="k.dutyPaid" />
<input type="hidden" class="hiddenhsCode" value="k.hsCode" />
<input type="hidden" class="hiddenidUom" value="k.idUom" />
<input type="hidden" class="hiddenunitPrice" value="k.unitPrice" />
<input type="hidden" class="hiddenuomCode" value="k.uomCode" />
<input type="hidden" class="hiddenidGrnforLot" value="k.idGrn" />
<input type="hidden" class="hiddenidPhysicalLocation" value="k.idPhysicalLocation" />
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="k.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">
<input type="hidden" class="hiddenLotQty" value="k.lotQty" />k.lotQty
</td>
<td class="cost"><input type="hidden" class="hiddencost" value="k.unitPrice" /> k.unitPrice
</td>
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails" ng-init="lotDetailsIndex = $index;">
<input type="hidden" class="hiddenLotDetails m-b-5" id="lotDetailsparentIndexlotDataChildIndexlotDetailsIndex" value="c"/> ctnchange : c<br>
</span>
</td>
<td class="trxQty p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="trxQtyIndex = $index;">
<!-- lotDetailsValues Hidden field -->
<input type="hidden" class="lotDetailsValues"
id="lotDetailsValuesparentIndexlotDataChildIndextrxQtyIndex"
ng-model="lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]" ng-init="(lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]) = k.lotDetailsValues[$index];"
value="k.lotDetailsValues[$index]" />
<!-- Transaction Quantity -->
<input class="trxQuantity m-b-5 text-right"
id="trxparentIndexlotDataChildIndextrxQtyIndex"
autocomplete="off"
ng-model="trx[parentIndex + '' + lotDataChildIndex + '' + trxQtyIndex]"
ng-keyup="calculateBalanceTxtQty(parentIndex,lotDataChildIndex,trxQtyIndex);
checkParentCheckbox($event,parentIndex,lotDataChildIndex);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- BALANCE AMOUNT HIDDEN -->
<td class="balance p-t-10 p-b-10" ng-hide="true">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceIndex = $index;">
<input ng-disabled="true"
class="balanceAmt m-b-5"
id="balAmtparentIndexlotDataChildIndexbalanceIndex"
type="text"
ng-model="balAmt[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"/><br>
</span>
</td>
<!-- BALANCE NEW AFTER CALCULATION -->
<td class="balanceNew p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceNewIndex = $index;">
<input type="text" style="width: 60px;"
ng-model="balNew[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"
ng-disabled="true"
class="balanceNew m-b-5 text-right"
id="balNewparentIndexlotDataChildIndexbalanceNewIndex"/>
<br>
</span>
</td>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
<tbody>
<tr ng-if="isDataLot=='no'" class="no_records"><td colspan="8">No Record(s) found.</td></tr>
<tr ng-if="isDataLot=='yes'" >
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-right">
<strong>Total:</strong>
</td>
<td class="text-right p-r-12">(addedTrxQty > 0) ? addedTrxQty : ''</td>
<td class="text-right p-r-12">(totalTrxValBal > 0) ? totalTrxValBal : ''</td>
</tr>
</tbody>
</table>
In order to get it in controller I used the following code:
var quantity = $scope.lotDetailsValues[parentIndex+ '' +childIndex+ '' +index];
add a comment |
I changed my HTML code to this :
<table id="lotTable" ng-table="tableSorting" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th ng-hide="true"></th>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th ng-hide="true">Balance</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index" ng-init="parentIndex = $index" id=parentRow$index data-id="l.lotNo">
<tr ng-repeat="k in l track by $index" ng-init="lotDataChildIndex = $index">
<td header-class="'text-center'" ng-hide="true">
<div class="checkbox">
<label>
<input type="checkbox" class="checkhead" id="lotHiddenCheckboxparentIndexlotDataChildIndex">
<em class="input-helper"></em>
</label>
</div>
</td>
<td class="indextrack" >$index+1
<input type="hidden" class="hiddenalcoholPer" value="k.alcoholPer" />
<input type="hidden" class="hiddencascCode" value="k.cascCode" />
<input type="hidden" class="hiddencreditorCode" value="k.creditorCode" />
<input type="hidden" class="hiddencreditorName" value="k.creditorName" />
<input type="hidden" class="hiddencustomAmnt" value="k.customAmnt" />
<input type="hidden" class="hiddenduty" value="k.duty" />
<input type="hidden" class="hiddendutyPaid" value="k.dutyPaid" />
<input type="hidden" class="hiddenhsCode" value="k.hsCode" />
<input type="hidden" class="hiddenidUom" value="k.idUom" />
<input type="hidden" class="hiddenunitPrice" value="k.unitPrice" />
<input type="hidden" class="hiddenuomCode" value="k.uomCode" />
<input type="hidden" class="hiddenidGrnforLot" value="k.idGrn" />
<input type="hidden" class="hiddenidPhysicalLocation" value="k.idPhysicalLocation" />
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="k.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">
<input type="hidden" class="hiddenLotQty" value="k.lotQty" />k.lotQty
</td>
<td class="cost"><input type="hidden" class="hiddencost" value="k.unitPrice" /> k.unitPrice
</td>
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails" ng-init="lotDetailsIndex = $index;">
<input type="hidden" class="hiddenLotDetails m-b-5" id="lotDetailsparentIndexlotDataChildIndexlotDetailsIndex" value="c"/> ctnchange : c<br>
</span>
</td>
<td class="trxQty p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="trxQtyIndex = $index;">
<!-- lotDetailsValues Hidden field -->
<input type="hidden" class="lotDetailsValues"
id="lotDetailsValuesparentIndexlotDataChildIndextrxQtyIndex"
ng-model="lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]" ng-init="(lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]) = k.lotDetailsValues[$index];"
value="k.lotDetailsValues[$index]" />
<!-- Transaction Quantity -->
<input class="trxQuantity m-b-5 text-right"
id="trxparentIndexlotDataChildIndextrxQtyIndex"
autocomplete="off"
ng-model="trx[parentIndex + '' + lotDataChildIndex + '' + trxQtyIndex]"
ng-keyup="calculateBalanceTxtQty(parentIndex,lotDataChildIndex,trxQtyIndex);
checkParentCheckbox($event,parentIndex,lotDataChildIndex);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- BALANCE AMOUNT HIDDEN -->
<td class="balance p-t-10 p-b-10" ng-hide="true">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceIndex = $index;">
<input ng-disabled="true"
class="balanceAmt m-b-5"
id="balAmtparentIndexlotDataChildIndexbalanceIndex"
type="text"
ng-model="balAmt[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"/><br>
</span>
</td>
<!-- BALANCE NEW AFTER CALCULATION -->
<td class="balanceNew p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceNewIndex = $index;">
<input type="text" style="width: 60px;"
ng-model="balNew[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"
ng-disabled="true"
class="balanceNew m-b-5 text-right"
id="balNewparentIndexlotDataChildIndexbalanceNewIndex"/>
<br>
</span>
</td>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
<tbody>
<tr ng-if="isDataLot=='no'" class="no_records"><td colspan="8">No Record(s) found.</td></tr>
<tr ng-if="isDataLot=='yes'" >
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-right">
<strong>Total:</strong>
</td>
<td class="text-right p-r-12">(addedTrxQty > 0) ? addedTrxQty : ''</td>
<td class="text-right p-r-12">(totalTrxValBal > 0) ? totalTrxValBal : ''</td>
</tr>
</tbody>
</table>
In order to get it in controller I used the following code:
var quantity = $scope.lotDetailsValues[parentIndex+ '' +childIndex+ '' +index];
I changed my HTML code to this :
<table id="lotTable" ng-table="tableSorting" class="table table-striped table-bordered table-vmiddle">
<thead>
<tr>
<th ng-hide="true"></th>
<th>S No.</th>
<th>Lot No.</th>
<th>Lot Qty</th>
<th>Unit Cost</th>
<th>Lot Details</th>
<th>Trx Qty</th>
<th ng-hide="true">Balance</th>
<th>Balance</th>
</tr>
</thead>
<tbody ng-if="isDataLot=='yes'" ng-repeat-start="l in lotData track by $index" ng-init="parentIndex = $index" id=parentRow$index data-id="l.lotNo">
<tr ng-repeat="k in l track by $index" ng-init="lotDataChildIndex = $index">
<td header-class="'text-center'" ng-hide="true">
<div class="checkbox">
<label>
<input type="checkbox" class="checkhead" id="lotHiddenCheckboxparentIndexlotDataChildIndex">
<em class="input-helper"></em>
</label>
</div>
</td>
<td class="indextrack" >$index+1
<input type="hidden" class="hiddenalcoholPer" value="k.alcoholPer" />
<input type="hidden" class="hiddencascCode" value="k.cascCode" />
<input type="hidden" class="hiddencreditorCode" value="k.creditorCode" />
<input type="hidden" class="hiddencreditorName" value="k.creditorName" />
<input type="hidden" class="hiddencustomAmnt" value="k.customAmnt" />
<input type="hidden" class="hiddenduty" value="k.duty" />
<input type="hidden" class="hiddendutyPaid" value="k.dutyPaid" />
<input type="hidden" class="hiddenhsCode" value="k.hsCode" />
<input type="hidden" class="hiddenidUom" value="k.idUom" />
<input type="hidden" class="hiddenunitPrice" value="k.unitPrice" />
<input type="hidden" class="hiddenuomCode" value="k.uomCode" />
<input type="hidden" class="hiddenidGrnforLot" value="k.idGrn" />
<input type="hidden" class="hiddenidPhysicalLocation" value="k.idPhysicalLocation" />
</td>
<td class="lotNo">
<input type="hidden" class="hiddenLotNo" value="k.lotNo"/>
k.lotNo <br>
k.grnNo (k.grnDate) <br>
k.inPermit k.physicalLocationName
</td>
<td class="lotQty">
<input type="hidden" class="hiddenLotQty" value="k.lotQty" />k.lotQty
</td>
<td class="cost"><input type="hidden" class="hiddencost" value="k.unitPrice" /> k.unitPrice
</td>
<td class="lotDetails" style=" line-height: 28px; ">
<span ng-repeat="c in k.lotDetails" ng-init="lotDetailsIndex = $index;">
<input type="hidden" class="hiddenLotDetails m-b-5" id="lotDetailsparentIndexlotDataChildIndexlotDetailsIndex" value="c"/> ctnchange : c<br>
</span>
</td>
<td class="trxQty p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="trxQtyIndex = $index;">
<!-- lotDetailsValues Hidden field -->
<input type="hidden" class="lotDetailsValues"
id="lotDetailsValuesparentIndexlotDataChildIndextrxQtyIndex"
ng-model="lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]" ng-init="(lotDetailsValues[parentIndex + '' + lotDataChildIndex + '' + $index]) = k.lotDetailsValues[$index];"
value="k.lotDetailsValues[$index]" />
<!-- Transaction Quantity -->
<input class="trxQuantity m-b-5 text-right"
id="trxparentIndexlotDataChildIndextrxQtyIndex"
autocomplete="off"
ng-model="trx[parentIndex + '' + lotDataChildIndex + '' + trxQtyIndex]"
ng-keyup="calculateBalanceTxtQty(parentIndex,lotDataChildIndex,trxQtyIndex);
checkParentCheckbox($event,parentIndex,lotDataChildIndex);addTrxQty();"
style="width: 60px;" integers-only/><br>
</span>
</td>
<!-- BALANCE AMOUNT HIDDEN -->
<td class="balance p-t-10 p-b-10" ng-hide="true">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceIndex = $index;">
<input ng-disabled="true"
class="balanceAmt m-b-5"
id="balAmtparentIndexlotDataChildIndexbalanceIndex"
type="text"
ng-model="balAmt[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"/><br>
</span>
</td>
<!-- BALANCE NEW AFTER CALCULATION -->
<td class="balanceNew p-t-10 p-b-10">
<span ng-repeat="c in k.lotDetails track by $index" ng-init="balanceNewIndex = $index;">
<input type="text" style="width: 60px;"
ng-model="balNew[parentIndex + '' + lotDataChildIndex + '' + balanceNewIndex]"
ng-disabled="true"
class="balanceNew m-b-5 text-right"
id="balNewparentIndexlotDataChildIndexbalanceNewIndex"/>
<br>
</span>
</td>
</tr>
</tbody>
<tbody ng-repeat-end></tbody>
<tbody>
<tr ng-if="isDataLot=='no'" class="no_records"><td colspan="8">No Record(s) found.</td></tr>
<tr ng-if="isDataLot=='yes'" >
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-right">
<strong>Total:</strong>
</td>
<td class="text-right p-r-12">(addedTrxQty > 0) ? addedTrxQty : ''</td>
<td class="text-right p-r-12">(totalTrxValBal > 0) ? totalTrxValBal : ''</td>
</tr>
</tbody>
</table>
In order to get it in controller I used the following code:
var quantity = $scope.lotDetailsValues[parentIndex+ '' +childIndex+ '' +index];
edited Apr 9 at 13:00
Wai Ha Lee
6,295124266
6,295124266
answered Apr 9 at 12:44
Abhiruchi MauryaAbhiruchi Maurya
33
33
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323794%2fhow-to-manage-naming-models-in-the-following-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You used the technique of
ng-init="parentIndex = $index"
on the topng-repeat
but then didn't use it. Its a good technique and less error prone than$parent.$parent.whatever
.– georgeawg
Mar 24 at 13:09