Show a button instead of text based on the current status

I have a dynamic table displaying various data, mostly text, but with a few buttons included.

Now, I need to figure out how to handle this

Here is the current data structure:

[ { "BET": 57630343, "CUSTOMER": 181645, "XX_FILL OPEN": true },
  { "BET": 57633044, "CUSTOMER": 181645, "XX_FILL OPEN": true },
  { "BET": 57633047, "CUSTOMER": 181645, "XX_FILL OPEN": true },
  { "BET": 57635034, "CUSTOMER": 181645, "XX_FILL OPEN": true } ]

This is how it looks:

https://i.stack.imgur.com/Lxz1x.png

If the data starts with XX..., it should be presented as a button. For example: "XX_FILL OPEN": true would become a button.

This is how I am currently rendering the table:

In the controller, I have the following code snippet:

  $scope.loadReports = function() {
    ReportsFactory.pendingBets(reportParam).then(function(data) {
      gridInfo = _.forEach(data, function(item) {return item;});
      $scope.rows = gridInfo;
      $scope.cols = Object.keys($scope.rows[0]);
    }

And in the HTML:

      <table>
        <thead>
          <tr>
            <th ng-repeat="column in cols">{{column}}</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="row in rows">
            <td ng-repeat="column in cols">{{row[column]}}</td>
          </tr>
        </tbody>
      </table>

So, my question is how can I change the display of true to a button whenever the data starts with XX...?

Answer №1

To implement a conditional statement with the use of ng-if on the occurrence of "XX" in each element of the column array...

<td ng-repeat="column in cols" ng-init="isXX = column.indexOf('XX') === 0">
    <span ng-if="!isXX">{{row[column]}}</span>
    <button ng-if="isXX">{{row[column]}}</button>
</td>

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

Upcoming topics - The Challenge of Staying Hydrated at Basecamp One

I have implemented a themes package for dark mode and light mode in my project. Despite doing the installation correctly as per the repository instructions, I am encountering an issue. My expected behavior for the project is: The webpage should initially ...

Utilizing a custom font to emphasize the extended phrase in the following sentence

I've been trying to use word-wrap to break long words into the next line, but unfortunately it's not working as expected. You can view my JsFiddle code for reference. The divs on my page are generated dynamically, and here is an overview of what ...

I encountered a 404 error while trying to implement an IIS 8 Rewrite rule

After implementing the Rewrite rule on IIS 8 for my asp.net application, I encountered a 404 error when trying to access www.mysiteurl.com/?_escaped_fragment_. Interestingly, changing the actionType to Redirect allowed successful redirection. <rule nam ...

Determine if a div contains an svg element with JavaScript

My question involves a div containing a question mark and some SVG elements. Here is the initial setup: <div id="mydiv">?</div> When validating a form submission in my code, I check if the div text contains a question mark like this: const f ...

When using Vue, the image element may not display the value stored in the object property

Excuse me for being new to Vue and struggling a bit. I'm attempting to display an image using a src that comes from an object property, which is retrieved from an array returned by data() I am not receiving any errors, but the icon is not appearing. ...

Exploring the world of Node.js with fs, path, and the

I am facing an issue with the readdirSync function in my application. I need to access a specific folder located at the root of my app. development --allure ----allure-result --myapproot ----myapp.js The folder I want to read is allure-results, and to d ...

Modify the MUI time picker to display as a digital clock inside a DateTimePicker widget

I need to update my MUI DateTimePicker component to use the DigitalClock time picker instead of the Analog Clock picker. The current component has two steps, first picking the date from a calendar and then selecting the time. This change is only necessary ...

Troubleshooting a malfunctioning ember.js HTML output

I'm currently facing a challenging debugging task to figure out why this specific code snippet is failing: Here is the template causing issues: <p class='navbar-text pull-right header-user-info'> {{#if currentUser.isSignedIn}} {{#i ...

"Enhancing Code Readability with Language-Specific Syntax Highlighting

My goal is to develop an editor that allows users to input code in various languages by selecting an option from a dropdown menu. The code should then be automatically highlighted based on the chosen language. I am considering using Codemirror for syntax ...

Attempting to engage with the like button on a Facebook page through Python's Selenium seems to be problematic

Here is the code for adding a (Facebook page like button): WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[1]/div/div[4]/div/div[1]/div/div[1]/div[2]/div[2]/div/div/div[3]/div/div[1]'))).click() The clic ...

Leveraging partials on their own

I am currently exploring the possibility of loading a partial in linkedin-dustjs without having to load its parent along with it. For instance, consider this partial (login.dust): {>layout/} {<content} <!-- Login Screen --> {/content} Th ...

The 'disabled' property is not found in the 'MatButton' type, however, it is necessary in the 'CanDisable' type

Issue found in node_modules/@angular/material/core/option/optgroup.d.ts: Line 17: Class '_MatOptgroupBase' does not correctly implement interface 'CanDisable'. The property 'disabled' is missing in type '_MatOptgroupBas ...

Start by creating a set of vertices and triangles to be utilized by the vertex shader

After experimenting with vertexshaderart.com, I'm eager to apply what I've learned on a different website. While I have experience using shaders in the past, some effects achieved on the site require access to vertices, lines, and triangles. Pass ...

Using the typeof operator to test a Typescript array being passed as an object

I have a puzzling query about this particular code snippet. It goes like this: export function parseSomething(someList: string[]): string[] { someList.forEach((someField: string) => { console.log(typeof someField) }) Despite passing a s ...

What is the best method for deleting an uploaded image from a box?

My code is quite lengthy, so I'll just showcase the JavaScript portion here. Here is a snippet of my JavaScript code: <script type="text/javascript"> let current = 0; for(let i = 0; i < 5; i++) { $('#thumbnail-view- ...

Steps for designing a movable image

I'm looking to implement a feature where the user can drag and drop an image anywhere on the page. Once the user places the image, its position will be saved so that when they revisit the page, it will be in the same location. Thank you! ...

Creating a harmonious relationship between a generator using recursion and promises

In Elasticsearch, it's feasible to make a "Scrolling" request. This method involves keeping a cursor open and retrieving large chunks of data gradually. Demo code is available for reference. The provided code uses callbacks and recursion to fetch dat ...

Ways to retrieve the initial key object received through an AJAX request

I have a form with three dynamic dropdowns. The second dropdown depends on the first one, and the third dropdown depends on the second one. Therefore, selecting an option in the first dropdown will automatically populate the next two dropdowns. Below is t ...

Unlimited Possibilities in Designing Shared React Components

Seeking the most effective strategies for empowering developers to customize elements within my React shared component. For example, I have a dropdown and want developers to choose from predefined themes that allow them to define highlight color, font siz ...

Using Function Call to Generate Components in React

Being tired of repeatedly defining states to render Components based on conditions, I often find myself just wanting to display notifications or alerts. My current dilemma is figuring out how to render a component by invoking a function from within that co ...