RepositoryTypeScriptGBVương quốc Anh
AndrewPoyntz

AndrewPoyntz/time-ago-pipe

An Angular pipe for converting a date string into a time ago

127sao
66fork
18issue
1lượt xem

⏳ time-ago-pipe — Định dạng thời gian tự nhiên trong Angular

Một Angular pipe siêu nhẹ, biến bất kỳ ngày nào thành dạng thân thương như 'một giờ trước', '2 ngày trước' chỉ bằng một dòng lệnh.

time-ago-pipe là một công cụ rất đơn giản nhưng hữu ích cho các dự án Angular, cho phép hiển thị thời gian dưới dạng tương đối một cách nhanh chóng và trực quan. Dự án được thiết kế nhẹ, hỗ trợ AOT (Ahead-of-Time) compilation, và có thể cài đặt ngay qua npm.

✨ Điểm nổi bật

  • Dạng thời gian tự nhiên: Tự động chuyển đổi ngày thành các dạng như 'một vài giây trước', 'một giờ trước', 'X ngày trước'.
  • Bảng ánh xạ rõ ràng: Định nghĩa rõ ranh giới thời gian cho từng đơn vị (giây, phút, giờ, ngày, tháng, năm).
  • Hỗ trợ AOT: Tương thích với quá trình build Ahead-of-Time của Angular.
  • Xử lý lỗi thông minh: Nếu giá trị đầu vào là null hoặc không hợp lệ, pipe sẽ không hiển thị gì.
  • Cài đặt nhanh: Chỉ cần một lệnh npm install và thêm vào mảng declarations trong module.
  • Sử dụng đơn giản: Áp dụng trực tiếp trong template bằng cú pháp {{ dateValue | timeAgo }}.

💡 Vì sao đáng chú ý

time-ago-pipe không cần bất kỳ cấu hình phức tạp nào — chỉ cần cài đặt và dùng ngay. Điều này giúp tiết kiệm thời gian phát triển, đặc biệt hữu ích trong các ứng dụng Angular nhỏ lẻ hoặc prototype. Ngoài ra, việc hỗ trợ AOT giúp tối ưu hiệu năng build ứng dụng.


#Angular #TimeAgo #Pipe #AOTCompatible #OpenSource #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryTypeScript
zhongsp/TypeScript

TypeScript 使用手册(中文版)翻译。http://www.typescriptlang.org

7.4k
Jul 5, 2026
RepositoryTypeScript
ihym/ngx-timeago

⏰ Live updating timestamps in Angular

80
Feb 5, 2026
RepositoryHTML
PatrickJS/awesome-angular

:page_facing_up: A curated list of awesome Angular resources

10.1k
Dec 1, 2026
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryTypeScript
freeCodeCamp/freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.

459.9k
Dec 2, 2026
RepositoryTypeScript
nilbuild/developer-roadmap

Interactive roadmaps, guides and other educational content to help developers grow in their careers.

373.1k
Dec 1, 2026
RepositoryTypeScript
firecrawl/firecrawl

Firecrawl is the knowledge infrastructure to make your agents smarter. It connects your agents to the web, and to Alexandria, our library of everything else.

215.1k
Dec 2, 2026
RepositoryTypeScript
vuejs/vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

212.6k
Oct 10, 2024
RepositoryPython
donnemartin/system-design-primer

Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.

379.9k
Sep 15, 2026