Displaying Edit and Delete options upon hovering over the data row

I'm working on a table that uses ng-repeat on the <tr> element. In the last column of each row, I have edit/delete links that should only be visible when the user hovers over the <tr> element.

<tr ng-repeat="form in allData | filter:search | orderBy: orderByValue : orderIn" ng-click="set_index($index)">
          <td><a ng-href={{form.link}}>{{form.ar_ref}}</a></td>
          <td>{{form.title}}</td>
          <td>{{form.category}}
            <span ng-class="{'show_edit_link', $index==selected_index}">
              <button ng-click="showUpdate()">Update</button>
              <button ng-click="showDelete()">Delete</button>
            </span>
          </td>
        </tr>

This is what my JS Controller looks like:

pp.controller('formsListCtrl', ['$scope', '$http', function($scope, $http){

  $http.get('/php_user/formJSON.php').success(function(response){
    $scope.allData=response; 

    //Show hover edit links
    $scope.selected_index = 0;
    $scope.set_index = function(i){ 
      $scope.selected_index = i;
    }

Here's the CSS for displaying the hover edit links:

.edit_link_show{
  display: inline;
}
.edit_link{
  display: none;
}

Answer №1

Your ng-controller is causing a syntax error. The expression after the class name should be followed by a colon and you need to add another ng-class argument for selected_index not equal to $index:

<tr ng-repeat="form in allData | filter:search | orderBy: orderByValue : orderIn" ng-click="set_index($index)">
          <td><a ng-href={{form.link}}>{{form.ar_ref}}</a></td>
          <td>{{form.title}}</td>
          <td>{{form.category}}
            <span ng-class="{'show_edit_link': $index==selected_index, 'edit_link': $index!=selected_index}">
              <button ng-click="showUpdate()">Update</button>
              <button ng-click="showDelete()">Delete</button>
            </span>
          </td>
        </tr>

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

Aligning labels vertically with inputs

How can I align all my input fields (image) to the same vertical line? I tried using the vertical-align css property and a sass mixin I found (see below), but neither seemed to work. @mixin vertical-align($pos) { position: $pos; top: 50%; -we ...

The HTML and CSS code I wrote functions perfectly on Codepen, but for some reason, it appears different when I view it in my Chrome environment

My codepen displays perfectly, but when I run the same code on my local environment it looks off. I can't seem to figure out what is causing the difference, especially since I copied and pasted the exact code. Both the codepen and my environment are u ...

Steps for Disabling col-sm and col-xs in Bootstrap 3

Hey there! I'm currently working on a template using Bootstrap 3. Initially, I planned to make it responsive for all devices, but I have since changed my mind and decided that the template is already complete. I've utilized col-md in each row, h ...

I'm attempting to slightly adjust the alignment of the text to the center, but it keeps causing the text to shift

I am facing an issue where I want to slightly center text, but whenever I add just 1px of padding-left, it moves to a new line. In my layout, I have 2 columns each occupying 50% width of the screen. One column contains only a photo while the other has a ba ...

Conflict between Angular's ng-repeat directive and Sass styling

Currently, I am working on a project and encountering an issue that is causing some difficulty: In order to create a navigation bar with equally distributed list elements based on the number of items, I am utilizing ng-repeat for data binding and Sass for ...

apply full width styling to bootstrap select dropdown

<div align="center" class="form-group"> <select v-model="subject" class="form-control"> <option v-for="n in papertypes" class="">{{ n.type }}</option> </select> <br> By default, Bootstrap makes the s ...

Prevent Scrolling of Body Content within a Specified Div

In my current situation, I am dealing with a large number of divs (over 300) that are being used as part of an interactive background. The issue arises when viewing the page on mobile versus desktop – there are too many divs on desktop, causing excessive ...

Angular.js guarantees fetching data with $http.get

I encountered an issue with my service that makes an $HTTP.GET request. Initially, I tried to access the object $$state but found that the value inside was undefined. To resolve this, I delved into learning about promises and asynchronous calls by reading ...

Check access tokens from various front-end applications (Client ID) with the help of okta-jwt-verifier

Is there a way to verify access tokens generated from multiple front end Angular apps using the same backend API by sending in an array of clientIds? const OktaJwtVerifier = require("@okta/jwt-verifier"); const oktaJwtVerifier = new OktaJwtVerifi ...

Protractor is having difficulty initializing a webdriver session

Can someone please assist me with this issue? Hello there! I'm having trouble running a protractor test as Chrome is only displaying a blank page. The error message indicates that the WebDriver could not be started. ✗ protractor config.js --trou ...

Incorrect date being sent by Mat Date picker

I am encountering an issue with date selection using this input field <mat-form-field class="w-full"> <mat-label>{{ "DATE" | translate }}</mat-label> < ...

Generating grid-style buttons dynamically using jQuery Mobile

I am in need of assistance to create a dynamic grid using jQuery Mobile. The grid should consist of buttons with either 'onclick' or 'href' functionality. The number of buttons should be generated dynamically at runtime. Specifically, I ...

Align the items at the center of a Vue Router Link

I am looking to design a navigation bar that includes router-link items, with each item displaying an icon on the left side and text on the right side. An example of this design can be seen in the Firebase navigation bar. https://i.sstatic.net/eg328.png ...

Optimizing responsiveness and side margins for high-resolution displays

Struggling with creating a website design with Bootstrap. My goal is to add margins on the sides when the screen size increases, but once I achieved it, the responsiveness of the page got disrupted. To incorporate the side margins, I enclosed the entire b ...

Utilizing SASS, JavaScript, and HTML for seamless development with Browser Sync for live syncing and

I've been on a quest to find a solution that covers the following requirements: Convert SASS to CSS Post-process CSS Minify CSS Move it to a different location Bundle all Javascript into one file Create compatibility for older browsers Tre ...

What is the best way to incorporate this video into this particular frame?

Does anyone know how to insert an image with a specific shape using SVG? I have the exact shape I want in an SVG file. Do I need to use relative or absolute positioning with respect to the SVG, or are there other solutions available? <svg width="90 ...

Encountering a module injection error in AngularJS related to the ui.grid feature during my first experience with it

Trying to develop an AngularJS app, encountering the following error upon running the code: Uncaught Error: [$injector:modulerr] Failed to create module myApp: Error: [$injector:modulerr] Failed to create module ui.grid: Error: [$injector:nomod] Module &a ...

Unable to process login information with form method post on basic login page

Hi, I've been struggling with a simple login page issue. It works fine with Bootstrap, but I want to switch to Angular Material Design. I've been searching for the problem for about 3-4 hours and can't find anything. I suspect that the form ...

Looking for assistance in using JavaScript to determine the percentage of a DIV's width in pixels

Using PHP, I am generating boxes whose width is set to 100% of a container in CSS. Now, I want to determine the equivalent pixel value of that box... HTML <div class="masonry" > <? while($row = $stmt->fetch()){ ?> <div class="i ...

Encountering a ModuleBuildError while setting up Tailwind CSS in Laravel 8

I am currently learning Laravel version 8 and encountered an issue while trying to install Tailwind CSS using the npm command. npm install tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9 Here is a detai ...