Text version of the video
http://csharp-video-tutorials.blogspot.com/2017/07/angular-custom-pipe.htmlHealthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1Slides
http://csharp-video-tutorials.blogspot.com/2017/07/angular-custom-pipe_18.htmlAngular 2 Tutorial playlist
https://www.youtube.com/playlist?list=PL6n9fhu94yhWqGD8BuKuX-VTKqlNBj-m6Angular 2 Text articles and slides
http://csharp-video-tutorials.blogspot.com/2017/06/angular-2-tutorial-for-beginners_12.htmlAll Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=ddAll Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlistsIn this video we will discuss creating a Custom Pipe in Angular. Let us understand this with an example.
Here is what we want to do. Depending on the gender of the employee, we want to display Mr. or Miss. prefixed to the employee name.
Step 1 : To achieve this let's create a custom pipe called employeeTitlePipe. Right click on the "employee" folder and add a new TypeScript file. Name it "employeeTitle.pipe.ts". Copy and paste the following code.
Code Explanation :
1. Import Pipe decorator and PipeTransform interface from Angular core
2. Notice "EmployeeTitlePipe" class is decorated with Pipe decorator to make it an Angular pipe
3. name property of the pipe decorator is set to employeeTitle. This name can then be used on any HTML page where you want this pipe functionality.
4. EmployeeTitlePipe class implements the PipeTransform interface. This interface has one method transform() which needs to be implemented.
5. Notice the transform method has 2 parameters. value parameter will receive the name of the employee and gender parameter receives the gender of the employee. The method returns a string i.e Mr. or Miss. prefixed to the name of the employee depending on their gender.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'employeeTitle'
})
export class EmployeeTitlePipe implements PipeTransform {
transform(value: string, gender: string): string {
if (gender.toLowerCase() == "male")
return "Mr." + value;
else
return "Miss." + value;
}
}
Step 2 : Register "EmployeeTitlePipe" in the angular module where we need it. In our case we need it in the root module. So in app.module.ts file, import the EmployeeTitlePipe and include it in the "declarations" array of NgModule decorator
import { EmployeeTitlePipe } from './employee/employeeTitle.pipe'
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent, EmployeeComponent, EmployeeListComponent, EmployeeTitlePipe],
bootstrap: [AppComponent]
})
export class AppModule { }
Step 3 : In "employeeList.component.html" use the "EmployeeTitlePipe" as shown below. Notice we are passing employee gender as an argument for the gender parameter of our custom pipe. Employee name gets passed automatically.
employee.name | employeeTitle:employee.gender
About the Site π
This site provides links to random videos hosted at YouTube, with the emphasis on random. π₯
Origins of the Idea π±
The original idea for this site stemmed from the need to benchmark the popularity of a video against the general population of YouTube videos. π§
Challenges Faced π€
Obtaining a large sample of videos was crucial for accurate ranking, but YouTube lacks a direct method to gather random video IDs.
Even searching for random strings on YouTube doesn't yield truly random results, complicating the process further. π
Creating Truly Random Links π οΈ
The YouTube API offers additional functions enabling the discovery of more random videos. Through inventive techniques and a touch of space-time manipulation, we've achieved a process yielding nearly 100% random links to YouTube videos.
About YouTube πΊ
YouTube, an American video-sharing website based in San Bruno, California, offers a diverse range of user-generated and corporate media content. π
Content and Users π΅
Users can upload, view, rate, share, and comment on videos, with content spanning video clips, music videos, live streams, and more.
While most content is uploaded by individuals, media corporations like CBS and the BBC also contribute. Unregistered users can watch videos, while registered users enjoy additional privileges such as uploading unlimited videos and adding comments.
Monetization and Impact π€
YouTube and creators earn revenue through Google AdSense, with most videos free to view. Premium channels and subscription services like YouTube Music and YouTube Premium offer ad-free streaming.
As of February 2017, over 400 hours of content were uploaded to YouTube every minute, with the site ranking as the second-most popular globally. By May 2019, this figure exceeded 500 hours per minute. π
List of ours generatorsβ‘
Random YouTube Videos Generator
Random Film and Animation Video Generator
Random Autos and Vehicles Video Generator
Random Music Video Generator
Random Pets and Animals Video Generator
Random Sports Video Generator
Random Travel and Events Video Generator
Random Gaming Video Generator
Random People and Blogs Video Generator
Random Comedy Video Generator
Random Entertainment Video Generator
Random News and Politics Video Generator
Random Howto and Style Video Generator
Random Education Video Generator
Random Science and Technology Video Generator
Random Nonprofits and Activism Video Generator