当前位置: 首页 > news >正文

angular实现list列表和翻页效果

说明:angular实现list列表和翻页效果
上一页 当前页面 下一页
效果图:
在这里插入图片描述

step1: E:\projectgood\ajnine\untitled4\src\app\car\car.component.css

.example-form-fields {display: flex;align-items: flex-start;
}mat-list-item{background: antiquewhite;
}

stp2: E:\projectgood\ajnine\untitled4\src\app\car\car.component.html

<button style="margin-top: 50px" mat-flat-button color="primary" (click)="inPassClick()">上一页</button>
<p>当前页数:{{this.onPage +1}}</p>
<button mat-flat-button color="primary" (click)="inNextClick()">下一页</button>
<button mat-flat-button color="primary" (click)="onNum()">当前数组</button><mat-nav-list><mat-list-item *ngFor="let user of users" (click)="onAddClick(user.id)"><span style="font-size: 20px;color: red;margin-right: 50px">{{ user.id }}</span><span>{{ user.name }}</span></mat-list-item>
</mat-nav-list>

step3:E:\projectgood\ajnine\untitled4\src\app\car\car.component.ts

import {Component, OnInit} from '@angular/core';
import {MatButton} from '@angular/material/button';
import {MatListItem, MatNavList} from '@angular/material/list';
import {NgForOf} from '@angular/common';@Component({selector: 'app-car',standalone: true,imports: [MatButton,MatListItem,MatNavList,NgForOf],templateUrl: './car.component.html',styleUrl: './car.component.css'
})
export class CarComponent implements OnInit {onPage: number = 0  //当前页数users: Details[] = []numLength = 3;  //最大页数 最小页数为0result: any = [];numPage = 3; /*每页显示条目数*/ngOnInit(): void {// let data = ['刘备','张飞','关羽','马超','诸葛亮','华雄','潘凤','赵云','孙权','曹操','吕布','董卓','貂蝉','孙尚香','周瑜','小乔',];for (let i = 0, len = userDatas.length; i < len; i += this.numPage) {this.result.push(userDatas.slice(i, i + this.numPage));}this.users = this.result[0]this.numLength = this.result.length - 1console.log(this.result);}inPassClick(): void {console.log('上一页')if (this.onPage > 0) {this.onPage--;}this.users = this.result[ this.onPage]}inNextClick(): void {console.log('下一页')if (this.onPage < this.numLength) {this.onPage++;}this.users = this.result[ this.onPage]}onNum(): void {console.log(this.onPage)console.log(this.result[this.onPage])}onAddClick(key: number): void {console.log(key)}}interface Details {id: number;name: string;avatar: string;details: string;isAdmin: boolean;isCool: boolean;
}const userDatas = [{id: 0,name: 'Lia Lugo',avatar: 'svg-11',details: 'I love cheese, especially airedale queso. Cheese and biscuits halloumi cauliflower cheese cottage ' +'cheese swiss boursin fondue caerphilly. Cow port-salut camembert de normandie macaroni cheese feta ' +'who moved my cheese babybel boursin. Red leicester roquefort boursin squirty cheese jarlsberg blue ' +'castello caerphilly chalk and cheese. Lancashire.',isAdmin: true,isCool: false},{id: 1,name: 'George Duke',avatar: 'svg-12',details: 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata ' +'corpora quaeritis. Summus brains sit, morbo vel maleficia? De apocalypsi gorger omero undead survivor ' +'dictum mauris.',isAdmin: false,isCool: true},{id: 2,name: 'Gener Delosreyes',avatar: 'svg-13',details: 'Raw denim pour-over readymade Etsy Pitchfork. Four dollar toast pickled locavore bitters McSweeney\'s ' +'blog. Try-hard art party Shoreditch selfies. Odd Future butcher VHS, disrupt pop-up Thundercats ' +'chillwave vinyl jean shorts taxidermy master cleanse letterpress Wes Anderson mustache Helvetica. ' +'Schlitz bicycle rights chillwave irony lumberhungry Kickstarter next level sriracha typewriter ' +'Intelligentsia, migas kogi heirloom tousled. Disrupt 3 wolf moon lomo four loko. Pug mlkshk fanny pack ' +'literally hoodie bespoke, put a bird on it Marfa messenger bag kogi VHS.',isAdmin: true,isCool: true},{id: 3,name: 'Lawrence Ray',avatar: 'svg-14',details: 'Scratch the furniture spit up on light gray carpet instead of adjacent linoleum so eat a plant, kill ' +'a hand pelt around the house and up and down stairs chasing phantoms run in circles, or claw drapes. ' +'Always hungry pelt around the house and up and down stairs chasing phantoms.',isAdmin: false,isCool: false},{id: 4,name: 'Ernesto Urbina',avatar: 'svg-10',details: 'Webtwo ipsum dolor sit amet, eskobo chumby doostang bebo. Bubbli greplin stypi prezi mzinga heroku ' +'wakoopa, shopify airbnb dogster dopplr gooru jumo, reddit plickers edmodo stypi zillow etsy.',isAdmin: false,isCool: true},{id: 5,name: 'Gani Ferrer',avatar: 'svg-16',details: 'Lebowski ipsum yeah? What do you think happens when you get rad? You turn in your library card? ' +'Get a new driver\'s license? Stop being awesome? Dolor sit amet, consectetur adipiscing elit praesent ' +'ac magna justo pellentesque ac lectus. You don\'t go out and make a living dressed like that in the ' +'middle of a weekday. Quis elit blandit fringilla a ut turpis praesent felis ligula, malesuada suscipit ' +'malesuada.',isAdmin: true,isCool: true},{id: 6,name: 'fans Ferrer',avatar: 'svg-17',details: 'Lebowski ipsum yeah? What do you think happens when you get rad? You turn in your library card? ' +'Get a new driver\'s license? Stop being awesome? Dolor sit amet, consectetur adipiscing elit praesent ' +'ac magna justo pellentesque ac lectus. You don\'t go out and make a living dressed like that in the ' +'middle of a weekday. Quis elit blandit fringilla a ut turpis praesent felis ligula, malesuada suscipit ' +'malesuada.',isAdmin: true,isCool: true}
];

end

相关文章:

angular实现list列表和翻页效果

说明&#xff1a;angular实现list列表和翻页效果 上一页 当前页面 下一页 效果图&#xff1a; step1: E:\projectgood\ajnine\untitled4\src\app\car\car.component.css .example-form-fields {display: flex;align-items: flex-start; }mat-list-item{background: antiquew…...

闯关leetcode——3285. Find Indices of Stable Mountains

大纲 题目地址内容 解题代码地址 题目 地址 https://leetcode.com/problems/find-indices-of-stable-mountains/description/ 内容 There are n mountains in a row, and each mountain has a height. You are given an integer array height where height[i] represents t…...

算法【Java】—— 动态规划之斐波那契数列模型

动态规划 动态规划的思路一共有五个步骤&#xff1a; 状态表示&#xff1a;由经验和题目要求得出&#xff0c;这个确实有点抽象&#xff0c;下面的题目会带大家慢慢感受状态标识状态转移方程初始化&#xff1a;避免越界访问 dp 表&#xff0c;所以在进行填表之前我们要预先填…...

idea连接docker并构建镜像

安装docker 安装docker idea连接docker 安装docker插件 设置docker连接 设置docker.exe 这个docker.exe是为了运行docker&#xff0c;可以通过安装docker desktop获取 docker desktop下载地址 右键图标找到文件位置 在同级的resource中 编写Dockerfile # 使用官方 Nginx…...

百度如何打造AI原生研发新范式?

&#x1f449;点击即可下载《百度AI原生研发新范式实践》资料 2024年10月23-25日&#xff0c;2024 NJSD技术盛典暨第十届NJSD软件开发者大会、第八届IAS互联网架构大会在南京召开。本届大会邀请了工业界和学术界的专家&#xff0c;优秀的工程师和产品经理&#xff0c;以及其它行…...

RedisTemplate类中的常用方法粗解(简单明了,预计5分钟看完)

在阅读项目代码过程中发现引用RedisTemplate 的方法操作redis时&#xff0c;都会有一些特定的ops &#xff0c;对此好奇就查资料的情况下有了本博客。 操作之前付一张我们项目中的用到的地方的图 另外本文中的语言用到的是Java&#xff0c;附上试验用到的redisTemplete依赖 <…...

鸿蒙ArkTS中的布局容器组件(Column、Row、Flex、 Stack、Grid)

在鸿蒙ArkTS中&#xff0c;布局容器组件有很多&#xff0c;常见的有&#xff1a;   ⑴ Column&#xff1a;&#xff08;垂直布局容器&#xff09;&#xff1a;用于将子组件垂直排列。   ⑵ Row&#xff1a;&#xff08;水平布局容器&#xff09;&#xff1a;用于将子组件水…...

显存占用 显存测试

目录 显存测试 显存占用示例 一个模型多卡占用 显存测试 import torch# 计算张量的大小&#xff08;例如&#xff1a;每个 float 占用 4 字节&#xff09; # 40GB 40 * 1024 * 1024 * 1024 字节 # 每个 float 4 字节&#xff0c;因此需要的 float 数量为 (40 * 1024 * 1024…...

快速入门CSS

欢迎关注个人主页&#xff1a;逸狼 创造不易&#xff0c;可以点点赞吗 如有错误&#xff0c;欢迎指出~ 目录 CSS css的三种引入方式 css书写规范 选择器分类 标签选择器 class选择器 id选择器 复合选择器 通配符选择器 color颜色设置 border边框设置 width/heigth 内/外边距 C…...

AcWing 1073 树的中心 树形dp (详解)

这道题目非常有新意&#xff0c;在过去&#xff0c;我们通常先访问子节点去更新父节点的状态&#xff0c;但是这道题我们还需要从父节点去更新子节点。 我们可以想象为向上和向下两个方向&#xff0c;我们任取一点&#xff0c;先向下走&#xff0c;再回来更新上面的点&#xf…...

modelscope下载Qwen2.5 72B 模型方法

conda create -n modelscope python=3.10 conda activate modelscopepip install modelscope执行这个python代码: from modelscope.hub.snapshot_download import snapshot_download# 下载模型到当前路径 model_dir = snapshot_download(...

重学SpringBoot3-整合 Elasticsearch 8.x (二)使用Repository

更多SpringBoot3内容请关注我的专栏&#xff1a;《SpringBoot3》 期待您的点赞&#x1f44d;收藏⭐评论✍ 整合 Elasticsearch 8.x &#xff08;二&#xff09;使用Repository 1. 环境准备1.1 项目依赖1.2 Elasticsearch 配置 2. 使用Repository的基本步骤2.1 创建实体类2.2 创…...

为什么说模拟电路的难点就在开通过程和关断过程?难在什么地方?

模拟电路中开通过程和关断过程之所以困难&#xff0c;主要有以下几个方面的原因&#xff1a; 1. 瞬态响应特性复杂 - 在开通和关断瞬间&#xff0c;电路中的电流和电压会发生快速变化&#xff0c;产生复杂的瞬态响应。这些瞬态响应可能包含过冲、下冲、振铃等现象&#xff0c;…...

CubeIDE BUG-project‘hello‘has no explict encoding set hello

projecthellohas no explict encoding set hello 解决方法&#xff1a; 点击红色处注册账号后登录&#xff0c;删除原本文件后重新生成即可。...

在线PDF转图片网站

https://www.ilovepdf.com/download/qgxkmbzgxt6yb3s8l9f7fc3q9606hq0bfh4b33mnrf3p7tp8l0d4qy386b5dxqwjbhq7j3j4tp20m4dnb89wA9jjw25br1gtAw42l0m1sq047nvld4qqrm8kzjplkAhw9458p4wjgbmn08g49l23c1khsggdx4A7z3m9xh19mgzdlllyA6r1/52 在线excel转图片 https://www.zamzar.c…...

ps和top的区别

时间上的区别&#xff1a; ps是静态查看进程而top是动态持续监控进程 功能上的区别 ps只是查看进程,top还可以监视系统性能,如平均负载,cpu和内存的消耗 ps 常用格式&#xff1a;ps -ef &#xff08;ef简洁aux详细 System &#xff36;风格和BSD 风格&#xff09; | grep P…...

自动驾驶上市潮中,会诞生下一个“英伟达”吗?

站上科技创新潮头的企业总是备受资本青睐。20世纪开始&#xff0c;从IT到互联网&#xff0c;IBM、英特尔、微软、苹果等各大科技巨头&#xff0c;你方唱罢我登场。 近几年&#xff0c;人工智能成为资本市场新传奇故事的孕育之地。今年10月&#xff0c;英伟达市值首度突破3.5万…...

CSS 计数器:深入解析与高级应用

CSS 计数器&#xff1a;深入解析与高级应用 CSS 计数器是前端开发中一个强大但经常被忽视的功能。它们允许开发者创建和管理自定义的计数序列&#xff0c;这在处理复杂文档结构时尤其有用。本文将深入探讨 CSS 计数器的原理、用法&#xff0c;并展示一些高级应用示例。 什么是…...

【真题笔记】15年系统架构设计师要点总结

【真题笔记】15年系统架构设计师要点总结 分布式数据库中各种透明RAID 5IPv6 IPv4电子商务系统项目配置管理IPO图&#xff08;输入加工输出图&#xff09;桥接模式的UML图面向对象设计原则软件测试 在15年真题练习中&#xff0c;对错题模棱两可的考点进行重点记录与内容延申。…...

斗破C++编程入门系列之三十九:多态性:纯虚函数和抽象类(四星斗师)

斗破C目录&#xff1a; 斗破C编程入门系列之前言&#xff08;斗之气三段&#xff09; 斗破C编程入门系列之二&#xff1a;Qt的使用介绍&#xff08;斗之气三段&#xff09; 斗破C编程入门系列之三&#xff1a;数据结构&#xff08;斗之气三段&#xff09; 斗破C编程入门系列之…...

不止是打字机效果:手把手教你用SpannableStringBuilder打造Android富文本AI对话界面

超越基础文本渲染&#xff1a;用SpannableStringBuilder构建专业级AI对话界面 在移动应用开发中&#xff0c;AI对话界面的用户体验往往决定了产品的专业度。传统的TextView虽然能显示文字&#xff0c;但要实现类似DeepSeek等专业AI产品的交互效果&#xff0c;需要深入掌握Andro…...

SDMatte开源大模型部署:本地化AI抠图替代PS,支持透明物体精细提取

SDMatte开源大模型部署&#xff1a;本地化AI抠图替代PS&#xff0c;支持透明物体精细提取 1. 产品概述 SDMatte是一款专注于高质量图像抠图的AI模型&#xff0c;特别擅长处理传统抠图工具难以应对的复杂场景。与Photoshop等传统工具相比&#xff0c;SDMatte通过深度学习技术实…...

AI模型评估指标:InstantID在各项基准测试中的表现

AI模型评估指标&#xff1a;InstantID在各项基准测试中的表现 【免费下载链接】InstantID 项目地址: https://ai.gitcode.com/hf_mirrors/InstantX/InstantID InstantID作为一款领先的AI模型&#xff0c;在多项基准测试中展现出卓越性能。本文将深入解析其在各项评估指…...

Z-Image-GGUF惊艳效果:运动模糊、景深虚化、镜头畸变等摄影级效果模拟

Z-Image-GGUF惊艳效果&#xff1a;运动模糊、景深虚化、镜头畸变等摄影级效果模拟 1. 项目简介&#xff1a;当AI学会“拍照” 想象一下&#xff0c;你告诉AI&#xff1a;“给我一张黄昏时分&#xff0c;一个女孩在樱花树下奔跑的照片&#xff0c;要有那种风吹过发丝的动感&am…...

轻舟体重管理大模型:赋能减重全病程管理,构建智能体重健康生态

在“健康中国2030”战略深入推进的背景下&#xff0c;慢性病防控与全民体重管理已成为公共卫生体系的重要议题。随着肥胖及相关代谢性疾病发病率持续上升&#xff0c;传统的体重干预模式已难以满足全人群、全生命周期的健康管理需求。在此趋势下&#xff0c;基于人工智能技术的…...

vue3 diff算法中的-双端 Diff + 最长递增子序列 讲解

一句话总结 Vue3 Diff 双端比较&#xff08;快速复用&#xff09; 最长递增子序列&#xff08;最小移动 DOM&#xff09; 目的&#xff1a;在乱序节点中&#xff0c;只移动最少 DOM&#xff0c;实现最高效更新。1. 先搞懂&#xff1a;Vue3 对比 Vue2 差在哪&#xff1f; Vue2…...

Java程序员的云原生时代生存指南:面向软件测试从业者的专业视角

在技术浪潮的冲击下&#xff0c;云原生已从概念演进为产业标准。对于广大Java程序员而言&#xff0c;这既是挑战也是机遇。传统的技术栈和开发模式正在经历深刻变革&#xff0c;而软件测试作为保障质量的关键环节&#xff0c;其理念与实践也随之迭代。 一、 挑战审视&#xff…...

西门子SMART200 PLC梯形图,SR20,昆仑通态触摸屏组态画面,常压电热水锅炉比例模糊...

西门子SMART200 PLC梯形图&#xff0c;SR20&#xff0c;昆仑通态触摸屏组态画面&#xff0c;常压电热水锅炉比例模糊控制追目标温度&#xff0c;PLC源触摸屏源CAD原理图图纸全套常压电热水锅炉那种“冰火两重天”的加热体验谁懂&#xff1f;茶水间或者小烘干池边上&#xff0c;…...

Vue2项目构建优化实战:时间戳防缓存与资源压缩的配置详解

1. 为什么Vue2项目需要构建优化 最近接手了一个老项目的维护工作&#xff0c;发现每次前端更新后总有用户反馈页面显示异常。排查后发现是浏览器缓存惹的祸——用户访问的仍然是旧版本的静态资源。这让我意识到构建优化的重要性&#xff0c;特别是对于需要频繁更新的业务系统。…...

LCC-LCC无线充电恒流/恒压闭环移相控制仿真 Simulink仿真模型,LCC-LCC谐振...

LCC-LCC无线充电恒流/恒压闭环移相控制仿真 Simulink仿真模型&#xff0c;LCC-LCC谐振补偿拓扑&#xff0c;闭环移相控制 1. 输入直流电压350V&#xff0c;负载为切换电阻&#xff0c;分别为50-60-70Ω&#xff0c;最大功率3.4kW&#xff0c;最大效率为93.6% 2. 闭环PI控制&…...