Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Create a custom filter in AngularJS

  • kudvenkat
  • 2015-11-11
  • 234963
Create a custom filter in AngularJS
angularjs custom filter examplecustom filter angularjscustom filter angularjs example
  • ok logo

Скачать Create a custom filter in AngularJS бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Create a custom filter in AngularJS или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Create a custom filter in AngularJS бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Create a custom filter in AngularJS

angularjs custom filter example
custom filter angularjs
custom filter angularjs example

In this video we will discuss how to create a custom filter in AngularJS.

Healthy 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.
   / @aarvikitchen5572  

Custom filter in AngularJS
Is a function that returns a function
Use the filter function to create a custom filter

Let us understand creating custom filter with an example.

Script.js : In the example below we are using the filter function to create a custom filter that converts integer values 1, 2, 3 to Male, Female and Not disclosed respectively. gender is the name of the filter. With in the filter function we have an anonymous function that returns another anonymous function. The input parameter for the inner anonynous function is the gender integer value. The switch statement in the function returns the corresponding string value.

var app = angular
.module("myModule", [])
.filter("gender", function () {
return function (gender) {
switch (gender) {
case 1:
return "Male";
case 2:
return "Female";
case 3:
return "Not disclosed";
}
}
})
.controller("myController", function ($scope) {

var employees = [
{ name: "Ben", gender: 1, salary: 55000 },
{ name: "Sara", gender: 2, salary: 68000 },
{ name: "Mark", gender: 1, salary: 57000 },
{ name: "Pam", gender: 2, salary: 53000 },
{ name: "Todd", gender: 3, salary: 60000 }
];

$scope.employees = employees;
});

HtmlPage1.html : In the view, we use the custom gender filter like any other angular built-in filter with a pipe character.

[!DOCTYPE html]
[html xmlns="http://www.w3.org/1999/xhtml"]
[head]
[title][/title]
[script src="Scripts/angular.min.js"][/script]
[script src="Scripts/Script.js"][/script]
[link href="Styles.css" rel="stylesheet" /]
[/head]
[body ng-app="myModule"]
[div ng-controller="myController"]
[table]
[thead]
[tr]
[th]Name[/th]
[th]Gender[/th]
[th]Salary[/th]
[/tr]
[/thead]
[tbody]
[tr ng-repeat="employee in employees"]
[td] {{ employee.name }} [/td]
[td] {{ employee.gender | gender}} [/td]
[td] {{ employee.salary }} [/td]
[/tr]
[/tbody]
[/table]
[/div]
[/body]
[/html]

In the above example we have the custom filter in Script.js file. In a real world application you may the custom filters in a separate script file (Filters.js for example). To do this reference the module object and use the filter function.

Filter.js : The custom filter is moved to a separate file

/// [reference path="Script.js" /]

app.filter("gender", function () {
return function (gender) {
switch (gender) {
case 1:
return "Male";
case 2:
return "Female";
case 3:
return "Not disclosed";
}
}
});

Script.js : After moving the filter function to a separate Filters.js file, the Script.js file will now look as shown below.

/// [reference path="angular.min.js" /]

var app = angular
.module("myModule", [])
.controller("myController", function ($scope) {

var employees = [
{ name: "Ben", gender: 1, salary: 55000 },
{ name: "Sara", gender: 2, salary: 68000 },
{ name: "Mark", gender: 1, salary: 57000 },
{ name: "Pam", gender: 2, salary: 53000 },
{ name: "Todd", gender: 3, salary: 60000 }
];

$scope.employees = employees;
});

HtmlPage1.html : The only change required in the view is to reference the Filters.js file
[script src="Scripts/Filters.js"][/script]

Link for all dot net and sql server video tutorial playlists
https://www.youtube.com/user/kudvenka...

Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspo...

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]