Using ng-repeat data to populate another function

I am looking to transfer the details of an order shown in an ng-repeat to another function within my controller. Currently, it works for the first item in the array. How can I extend this functionality to display any order currently visible on the page?

When the detail button is clicked, the necessary URL is generated. I want this URL to be created for whichever order is being displayed on the detail page at that time. While it currently only works with the first item in the array, how can I make it work for other orders as well?

https://plnkr.co/edit/nASmvcPakxKpRXDsfKnW?p=catalogue

app.js


// Unique content will replace this code block

detail.html


// Unique content will replace this code block

JSON data


// Unique content will replace this code block

Answer №1

Ensure to integrate the button within the ng-repeat loop and transmit the order to your pay() scope function so that it can subsequently be passed to onPay() without relying on the fixed var order = $scope.orders[0];

HTML

<ion-item class="item-text-wrap" 
          ng-repeat="order in orders | filter: { bkor_user: whichorder }">
    <h1>Production Name: {{order.bkev_name}}</h1>
    <h3>Seatcount: {{order.bkor_seatcount}}</h3>
    <h1>Order Subtotal: £{{order.bkor_subtotal}}</h1>
    <button class="button button-block button-dark" ng-click="pay(order);">Pay Here</button> <-- reposition this and send 'order'
</ion-item>

Controller

function onPay(order) {
    var itemsArr = [];
    var invoice = {};
    var myItems = {};
    var myItem = {};
    // var order = $scope.orders[0]; <-- exclude this
    [ ... ]
}

$scope.pay = function (order) {
    var url = onPay(order); <-- transmit order
    window.open(url, "_system");
}        

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Controlling the behavior of React components in response to updates

I'm currently learning ReactJs and utilizing the ExtReact framework for my project. I have successfully implemented a grid with pagination, which is functioning well. I customized the spinner that appears during data loading and it works as expected ...

The API Key containing a colon is causing a TypeError when trying to parse it because forEach is not recognized as a function

Trying to utilize the New York Times API to fetch the Top Stories in JSON, I am encountering an issue: Uncaught TypeError: top.forEach is not a function Suspecting that the problem lies with the API key containing colons in the URL, I attempted encoding ...

What benefits can be gained from utilizing the beforeEach function within Jest testing?

I am currently immersing myself in the world of Jest by following this informative guide. Can you explain the benefits of utilizing the beforeEach function in Jest? I have a particular interest in identifying action dispatches. I believe that two segments ...

How can a PrivateRoute component effectively handle waiting for an asynchronous response?

I've encountered an issue with my PrivateRoute component that is supposed to verify the validity of a token. The problem lies in the fact that the validation process for rendering a view is not functioning as expected, always rendering: App.js const ...

react-query: QueryOptions not functioning as expected when utilizing userQueries()

When passing certain "query options" while using useQueries() to fetch multiple queries simultaneously, these specified "query options" do not get applied during query executions (e.g. refetchOnWindowFocus has a value of true but I want it to be false). F ...

Transmitting JSON information to a Spring Controller

I am experiencing an issue while attempting to transmit JSON data from an Angular POST request to a Spring controller. The console shows a 404 error: POST http://localhost:8080/app/orderDetails/saveOrder/[object%20Object],[object%20Object] 404 (Not ...

Error in processing large XML data: socket disconnect during express request

In my current project, I am facing the challenge of parsing a large 300MB XML file into JSON within a worker Node.js application. The workflow involves the client making a request to the main web app, which in turn sends a request to the worker server with ...

Is there a way to dynamically access BEM-style selectors using CSS modules?

For instance, I have this specific selector in my App.module.css file: .Column--active I want to access this selector from the App.js file in React using CSS modules. After importing all selectors from the CSS file as import styles from './App. ...

Tips for applying ng-class to elements in AngularJS that need to be styled both conditionally

What is the best way to achieve success in this task? ng-class="{'a':x, 'b':::y}" I am attempting to apply 'y' only once and not bind it with 'x'. I have also experimented with using multiple ng-class directives: ...

The validator function is causing an error with the 'lowerCase()' method resulting in an undefined output

Dealing with email validation in a form, I encountered a case-insensitivity issue. Using the angular validation mustMatch to ensure emails match index for index, I needed to address the case sensitivity. This led me to create the matchCaseInsensitivity fun ...

Display React elements on the web page

Seeking assistance from anyone! I've been grappling with a problem and can't seem to figure out a solution. Here's the scenario: My current setup involves a sidebar and a top bar for navigation in React. Check out my app so far in this imag ...

prevent unnecessary duplicate database queries for generating metadata in the upcoming 13 or 14 instances

In the latest updates, version 13 and 14 of Next introduced the usage of the generateMetadata function as the preferred method to define all page metadata. However, a drawback of this approach is that because of the separation of logic, fetching data base ...

Update the styling for the second list item within a specified unordered list class instantaneously

Looking to emphasize the second list item (li) within a selected dropdown list with a designated unordered list class of "chosen-results". <div class="chosen-container chosen-container-single select-or-other-select form-select required chosen-proc ...

Ways to retrieve a grandchild element of a specific element using its tag name

I'm struggling to access elements that are nested within various levels of parent elements with and without IDs. The usual method getElementByTagName doesn't seem to be working for me, especially when the target element is three levels deep. Is t ...

ng-model assigns the value to the select

Below is the angularjs directive I have created: dicApp.directive('listpanel', function ($resource) { return { restrict: 'E', template: '<select ng-model="selectedDictionary" ng-change="listChange()">&apo ...

Unable to access this context in Firefox debugger after promise is returned

I'm curious as to why the 'this' object is not showing up in the debugger in Firefox, but it does appear in Chrome's debugger. When I try to access 'this.myProperty', it shows as undefined. This is the code from my TypeScript ...

I encountered an issue when attempting to execute an action as I received an error message indicating that the dispatch function was not

I just started learning about redux and I am trying to understand it from the basics. So, I installed an npm package and integrated it into my form. However, when I attempt to dispatch an action, I encounter an error stating that 'dispatch is not defi ...

Preserving CSS styling while loading an HTML page with InnerHTML

By using the following code snippet, I have successfully implemented a feature on my website that allows me to load an HTML page into a specific div container when clicking a link in the menu. However, I encountered an issue where the background color of ...

The class "pagination pagination-lg" from the link https://angular-ui.github.io/bootstrap/#/pagination seems to be malfunctioning in Bootstrap 4

Just starting out with angularjs and I'm trying to implement pagination using https://angular-ui.github.io/bootstrap/#/pagination. However, I'm facing an issue where the style class "pagination pagination-lg" is not applying properly. I'm cu ...

What is the best way to dynamically add the 'required' attribute to an input field?

My responsibility was to dynamically add required fields to all elements on each state that the user selected as required. In my database, I have a table containing the input ID (each input has a unique ID) and a boolean field indicating whether or not a r ...