Icons that are clickable in ionic

I have successfully created a list card with 2 icons in each row. However, I am facing a challenge in making these icons clickable without disrupting the layout of the list. I attempted to add an ng-click to the icon element, but it did not work as expected. Additionally, surrounding the icons with a div caused me to lose the original layout of the list.

<div class="list card">
  <div ng-repeat="destination in destinations | isActive">
    <div class="item item-divider">
      <span>{{title}}</span>
    </div>
    <a href="#" class="item item-icon-left item-icon-right item-balanced">
      <i class="icon ion-ios-home"></i>
      <div>
        <div>{{text1}}</div>
        <div><b>{{text2}}</b></div>
        <div>{{text3()}}</div>
        <div>{{text4()}}</div>
      </div>
      <i class="icon ion-ios-filing"></i>
    </a>
  </div>
</div>

My goal is to maintain the current layout with the two icons positioned on the left and right sides.

Answer №1

Transform the link tag into a div tag, and change your i tag to a link tag. Don't forget to include some CSS for the icon styling. All set!

(See Demo)

HTML

<div class="list card">
    <div ng-repeat="destination in destinations | isActive">
        <div class="item item-divider">
            <span>{{title}}</span>
        </div>
        <div class="item item-icon-left item-icon-right item-balanced">
            <a href="#" class="icon ion-ios-home"></a>
            <div>
                <div>{{text1}}</div>
                <div><b>{{text2}}</b>
                </div>
                <div>{{text3()}}</div>
                <div>{{text4()}}</div>
            </div>
            <a href="" class="icon ion-ios-filing"></a>
        </div>
    </div>
</div>

CSS

.icon {
    color: inherit;
    text-decoration: none;
}

Answer №2

When working with Ionic 3, you can use the following code snippet:

<ion-card class="border-top" (click)="eventDetail(event.id)">
        <ion-card-content>
          <ion-card-title>
            {{ event.title }} <ion-badge color="primary"> {{ event.date | date : "MMMM d, yyyy - HH:mm"}}</ion-badge>
          </ion-card-title>
          <p>
            {{ event.description }}
          </p>
        </ion-card-content>
      </ion-card>

In this example, eventDetail is a function within the corresponding class and eventId is the value being passed.

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

What is the best way to simulate a method on the $scope object within an Angular function using Jasmine?

I've been handed some malfunctioning tests that need fixing. Our setup involves using Angular 1.5 with Jasmine. In a 'real' controller, the code looks like this: function myfunction() { $scope.stop = function() { $interval.cancel(pro ...

The CSS :not selector does not work as intended

My goal is to assign the class no-color to a specific tag. When JavaScript is enabled, I want this class to be removed and the text to be colorized. However, my current CSS solution is not working as expected. Below is a sample code snippet demonstrating t ...

Minimizing the menu bar while scrolling down (bootstrap3)

Could anyone help me with creating a navigation-bar effect similar to the one seen on ? I want the bar to shrink and the logo to change after scrolling down my page. My website is built using bootstrap 3. Is there a simple way to achieve this effect with ...

Troubleshooting material design CSS problem in AngularJS routing module

Attempting to incorporate material design with routing in angular js, but encountering issues with CSS design not working. Interestingly, when using bootstrap CSS, it functions properly. Check out the Plnker Demo here However, upon trying this approach, ...

Enhancing NG Style in Angular 6 using a custom function

Today, my curiosity lies in the NG Style with Angular 6. Specifically, I am seeking guidance on how to dynamically update [ngStyle] when utilizing a function to determine the value. To better illustrate my query, let me present a simplified scenario: I ha ...

Adapting Classes in Javascript Based on Screen Width: A Step-by-Step Guide

I'm dealing with two separate menus - one for mobile version and one for PC version. However, the mobile menu seems to be overlapping/blocking the PC menu. How can I resolve this issue? I've attempted various solutions such as removing the mobil ...

Are there ways to implement Vue.js transitions without directly setting the height in the code?

I'm having an issue with a Vue app I created where I need to make an element expand and collapse when a button is clicked. I want the effect to be smooth and animated, but using the <transition> tag alone isn't working as expected. The prob ...

I'm wondering if anyone has any insights as to why the CSS rule `body{ overflow: auto;}` is not functioning properly for me. Despite my attempts of adding a class to the body tag and

I am facing an issue where adding body tags to my code in Visual Studio code does not yield the desired results. Interestingly, it doesn't seem to be a syntax error in CSS. body{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI&apo ...

Properly storing information in the mongoDB

Having trouble saving data in my Angular application correctly. Here is a snippet of my API code: .post('/type/add', function(req, res){ var type = new NewType({ type: req.body.type, subtype: req.body.subtype, }); type.save ...

Eliminate any excessive space located at the bottom of the table

How can we adjust the spacing at the bottom of the table to remove extra space? Currently, it looks like this: https://i.stack.imgur.com/DwkbG.png We want it to look like this: https://i.stack.imgur.com/extDP.png CSS .wk_mp_body td { background: ...

Troubleshooting a Problem with AngularJS $.ajax

Oops! Looks like there's an issue with the XMLHttpRequest. The URL is returning a preflight error with HTTP status code 404. I encountered this error message. Any thoughts on how to resolve it? var settings = { "async": true, "crossDomain": ...

Adjust the order of list items based on the resolution change

Is there a way to rearrange the order of the list items in an ul when the screen resolution changes, specifically having the last li appear in the first place? Edit: I am attempting to achieve this by using flexbox. .postpreview ul { list-style: none; d ...

Step-by-step guide on showcasing an image within the sidebar-wrapper CSS class

I am trying to include an image in the #sidebar-wrapper class using the code below: CSS: #sidebar-wrapper { background-image:url('/images/nav.jpg'); margin-left: -250px; left: 250px; width: 250px; position: fixed; height: 100%; ov ...

CSS - Organization of Rows and Columns

I am in the process of designing a website that will feature news content, and I would like to give it a layout similar to a reddit news box. The layout would resemble the following structure. I am using angular material and CSS exclusively, without any fr ...

Exploring the Power of Constants in Karma and Jasmine for Enhanced Performance

To sum it up: I prefer storing hard-coded values in a separate file for reuse across multiple test specifications. Explaining further: Currently following the AngularJS tutorial, I am aiming to write more organized code. In step 5, they mention using hard ...

Launch another modal and then deactivate the initial modal

Having two Modals has presented a challenge for me when it comes to closing the first modal after the second one is opened. I attempted a solution, but it prevented the second Modal from opening altogether. This code snippet below belongs to the first Mo ...

Revolving mechanism within React.js

I am currently developing a lottery application using React.js that features a spinning wheel in SVG format. Users can spin the wheel and it smoothly stops at a random position generated by my application. https://i.stack.imgur.com/I7oFb.png To use the w ...

When watching YouTube videos in full screen mode on F11, the IFrame zooms in excessively, causing the video quality to suffer

After using the same code as the website Virtual Vacation, I noticed that they are experiencing the same issue as me. I am considering reaching out to them to inform them about it, but I am struggling to find a solution on my own. Specifically on WINDOWS ...

Navigating a intricate JSON framework with the power of AngularJS

Is there a way to access multiple objects' properties from a JSON object using AngularJS? <li ng-repeat='customer in customers[$index][data]["DisplayName"] | filter:search'>{{ customer }}</li> This code snippet allows for loopi ...

How can we manage a discovered item in Promise and Recursion scenarios without relying on a callback function?

I need to iterate asynchronously and recursively over a folder hierarchy on the server. When a file is found, I want to call a custom method. Here's my current code structure: searchFile(root, handleFile); // recursively loop through folders and ha ...