This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1597|Reply: 0

[Angular] Angular 18 series (twenty-four) custom string truncation pipes

[Copy link]
Posted on 10/16/2024 5:21:50 PM | | | |
Requirements: If the username of the Angular page is too long, it will be truncated, and you need to implement the Pipe pipeline to capture the string.

Review:

Angular 9 Series (IV) Custom Pipe pipelines
https://www.itsvse.com/thread-9248-1-1.html
The renderings are as follows:



First, create a new TruncatePipe pipeline using the angular-cli command, which is as follows:

The code is as follows:

example

public longStr = 'A really long string that needs to be truncated';

<h1>{{longStr | truncate }}</h1>
<!-- Outputs: A really long string that... -->

<h1>{{longStr | truncate : 12 }}</h1>
<!-- Outputs: A really lon... -->

<h1>{{longStr | truncate : 12 : true }}</h1>
<!-- Outputs: A really... -->

<h1>{{longStr | truncate : 12 : false : '***' }}</h1>
<!-- Outputs: A really lon*** -->
Reference:The hyperlink login is visible.





Previous:.NET/C# converts field names to small hump, large hump
Next:Angular 18 series (twenty-five) dynamically inserts rendered HTML code
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com