I am having trouble finding a way to get the index off of a property on a razor file. I need to match the index of the table to the array that I have on scope.
I set a window value from my cshtml file to a scope property.
scope.discountFlightList = dealViewModel;
dealViewModel contains an array of items. Most importantly deal.Fare
I need to access a certain index of the array each time the button located on the razor file is clicked. Below is the button that I am working with.
<a href="" ng-click="openPriceChart()" class="btn-primary btn-sm pull-right hide-on-mobile"><span ng-bind-html="@deal.Fare | roundPrice | superCurrency: '@Language.Currency' : true"></span>* <i class="ha-icon fontIcon-angle-right"></i></a>
The index that I need is based on the fare value that I can see on ng-init which exists on each td of
<td ng-init="myInit('@deal.OriginText')"> // in dev tools = San Francisco, California
Ideally I would know what the index is when I click on the a href and set it to the array index. I was hoping this answer would do it How can I pass @Model to Angular ng-init
var testValue
$scope.myInit = function(name){
testValue = name;
}
But I am getting an empty string when I check on my debugger.
Since the razor file is using a foreach as opposed to the ng-repeat I don't see how I can use $index.
@foreach (var deal in @Model.Deals.Take(Model.NumberOfFaresToDisplay ?? 6))
{
Any help would be greatly appreciated.