简体   繁体   English

当用户单击 ion-item 中的任何项目时打开新页面

[英]Open new page when User Click on any item from ion-item

Here is the codepen这是codepen

1) I want to open new details page, when user click on item and want to show details of that clicked item in newly opened back. 1)我想打开新的详细信息页面,当用户点击项目并希望在新打开的背面显示该点击项目的详细信息。
2) On details page there would be "OK" button if user click on that button then it would be back to list page. 2)在详细信息页面上,如果用户单击该按钮,将返回“确定”按钮,然后它将返回列表页面。
3) How Can i show marked circle icon on right side of the list item. 3)如何在列表项的右侧显示标记的圆圈图标。

How Can I do this?我怎样才能做到这一点? I spent 2 hours but I have not found any working solution.我花了 2 个小时,但没有找到任何有效的解决方案。

Please help me.请帮我。 I am new in ionic and angular js.我是 ionic 和 angular js 的新手。

Add something like this to your css: 在您的CSS中添加以下内容:

ion-list div ion-item i {
  float: right;
  position: relative;
}

You may need to add a line like: 您可能需要添加以下行:

top: -20px;

to tweak the positioning. 调整位置。

you should read about states and then create one for each element of you list and one for the list itself. 您应该阅读有关状态的信息 ,然后为列表的每个元素创建一个,并为列表本身创建一个。 After that all you need it's to call $state.go('nameOfState'); 之后,您所需要的就是调用$state.go('nameOfState'); Not sure if there is a way to do it just with ionic itself... 不确定是否有办法仅靠离子本身来做到这一点...

Here is a workaround;这是一个解决方法; Question 1) Add an onclick event to each ion-item which links up to a method to process the event.问题 1) 向每个离子项添加一个 onclick 事件,该事件链接到处理事件的方法。 The callback will handle routing to the details page while appending the list page URL as a prop or as a route query parameter回调将处理路由到详细信息页面,同时将列表页面 URL 作为 prop 或作为路由查询参数附加

Question 3) Ionic 5 + has this already in place.问题 3) Ionic 5 + 已经准备好了。 You can simply use the slot attribute to position items within the ion-item Here is a sample code that covers all the above您可以简单地将 slot 属性用于 ion-item 中的 position 项目这是一个涵盖以上所有内容的示例代码

          <h4> {{ product.name }} ({{ product.sku }})</h4>

          <ion-row>
            <ion-col class="separator" size-md="4" size-xs="12">

              <small>Selling Price: {{ product.selling_price }}</small>
            </ion-col>
            <ion-col class="separator" size-md="4" size-xs="12">

              <small> Cost Price: {{ product.cost_price }} </small>

            </ion-col>

          </ion-row>
        </ion-label>
        <ion-buttons>
          <ion-button fill="clear" slot="end" @click="editProduct(product._id)">
            <ion-icon :icon="createOutline" slot="icon-only"></ion-icon>
          </ion-button>
          <ion-button fill="clear" slot="end" @click="deleteProduct(product._id)">
            <ion-icon :icon="trashOutline" slot="icon-only"></ion-icon>
          </ion-button>
        </ion-buttons>

      </ion-item>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM