This project is a comprehensive example demonstrating how pipes are used in Angular. It showcases various Angular pipes using characters from "The Lord of the Rings".
- String Pipes: uppercase, lowercase, titlecase
- Number Pipes: number, decimal, percent, currency
- Date Pipes: date (various formats)
- Object & Array Pipes: json, slice, keyvalue
- Async Pipe: Working with Observables
- Chaining Pipes: Using multiple pipes together
- Boolean Pipes: Custom boolean value formatting
- Custom Pipes: RaceIcon and RingBearer custom pipes
- Pure vs Impure Pipes: Interactive demo showing differences
- Node.js (v14 or higher)
- npm (v6 or higher)
- Angular CLI (v16 or higher)
# Clone the repository
git clone https://github.com/sametacar/angular-pipe-examples.git
# Navigate to the project directory
cd angular-pipe-examples
# Install dependencies
npm install
# Start the development server
ng serveOpen your browser and navigate to http://localhost:4200/ to see the application.
- uppercase: Converts text to uppercase
- lowercase: Converts text to lowercase
- titlecase: Capitalizes the first letter of each word
- date: Displays dates in various formats (short, medium, long, custom)
- number: Formats numbers
- decimal: Formats decimal numbers
- percent: Displays numbers as percentages
- currency: Currency formatting
- json: Displays objects in JSON format
- slice: Slices arrays
- keyvalue: Displays objects as key-value pairs
- Working with Observable data
- Pure pipes only execute when the input reference changes
- Impure pipes execute on every change detection cycle
This project includes two custom pipes:
- RingBearer Pipe: Shows whether a character is a ring bearer or not
- RaceIcon Pipe: Displays an icon based on the character's race
The project includes an interactive demo showing the difference between pure and impure pipes. This demo demonstrates:
- Pure pipes only execute when the input reference changes
- Impure pipes execute on every change detection cycle
- Pure pipes don't update when object content changes but the reference remains the same
This project is licensed under the MIT License - see the LICENSE file for details.
This project was created to showcase Angular's powerful pipe system. If you'd like to contribute, please submit a pull request or open an issue.