AngularJS – Directive & Filter 介紹篇
為了方便文章閱讀,本篇將filter翻譯成過濾器、directive翻譯成指示指令
在看過前幾篇的AngularJS的教學後,我們對AngularJS的開發應該有了基本的認識,針對HTML文件中我們的操作有:
針對頁面引入應用程式模組
<html ng-app="store">
針對頁面引入控制器
<body ng-controller="StoreController as store">
針對頁面去顯示或隱藏元素
<h1 ng-show="name">Hello, {{ name }} !</h1>
針對大量的資料設定重複的區域
<li ng-repeat="product in store.products">{{ product.name }}</li>
接下來針對過濾器來介紹,依下圖所示產品價格的部分,有的是有小數點有的沒有,會造成頁面在資料呈現上的參差不齊。
若我們在該表達式(expression)加上一條直線(pipe),在直線後面可以加入一些過濾器,本範例加入的是貨幣格式的過濾器,當加入後價格在頁面上顯示的格式,就會自動加上了$符號和兩位數的小數點。
我們也可以在過濾器後面利用冒號再加上一些選項,讓呈現的資料更不同,例如下圖中date格式中是以「月/日/年 @ 時:分AM」這樣的方式顯示,而除了貨幣currency、日期date的過濾器之外,還包含有大小寫轉換的uppercase、lowercase、字數也可以當成資料呈現筆數的limitTo、另外還有可以針對重複性的資料進行排序的orderBy,大概的使用方式可以參考下圖,或是在JS Bin看看馬老師製作的案例。
另外關於指示指令部分,在這次的案例上我們加上產品的圖片,圖片的部分有兩種,一個是大圖;另一個是產品的縮圖,也因為有兩種不同的資料,要注意他被加在數列裡面的方式。
在頁面上顯示圖片的方式要注意不是用src的屬性去呈現,而是需要用ng-src這個屬性,加上圖片欄位的表達式即可,在JS Bin上面觀賞本案例程式碼。
※以上截圖部分為AngularJS官方教學視訊,另有filter指令介紹的專頁和所有filter清單。
my canadian pharmacy canadian pharmacy no scripts canadian drug
Здравствуйте!
Как приобрести диплом о среднем образовании в Москве и других городах
marandola.net/dokuwiki/doku.php?id=premialniediploms24
Окажем помощь!.
Официальная покупка диплома вуза с сокращенной программой в Москве
Здравствуйте!
Мы изготавливаем дипломы любых профессий по приятным тарифам.
pedlamrisk.com/page4.htm
https://easyrxindia.shop/# india pharmacy
Привет, друзья!
Как быстро и легально купить аттестат 11 класса в Москве
balipraia.com/tag/balipraia
Здравствуйте!
Приобретение диплома ПТУ с сокращенной программой обучения в Москве
старый.ркэ.рф/index.php/component/k2/itemlist/user/127651
Рады оказать помощь!.
Добрый день!
Приобрести документ о получении высшего образования можно в нашей компании в Москве.
hnfmrfdtg.gallery.ru
Привет, друзья!
Мы изготавливаем дипломы.
odessaflower.ukrbb.net/viewtopic.php?f=55&t=25568
Покупка диплома о среднем полном образовании: как избежать мошенничества?
best online pharmacy india: online shopping pharmacy india – pharmacy website india
Привет!
Диплом о высшем образовании
telegra.ph/kupit-diplom-belarus-08-22-2
Добрый день!
Диплом для вас
mediamemorial.ru/club/user/125807/forum/message/3881/13363/#message13363
Привет!
Заказать диплом о высшем образовании
ninokuni.ru/member.php?action=profile&uid=3583
п»їlegitimate online pharmacies india: pharmacy website india – pharmacy website india
Hi there! This post couldn’t be written any better! Reading this post reminds me of my previous room mate! He always kept chatting about this. I will forward this article to him. Fairly certain he will have a good read. Many thanks for sharing!
mexican pharmaceuticals online: mexican online pharmacies prescription drugs – mexico drug stores pharmacies
top online pharmacy india: pharmacy website india – online shopping pharmacy india
cross border pharmacy canada vipps approved canadian online pharmacy canadian pharmacy 24 com
Здравствуйте!
Приобрести диплом о высшем образовании
polkasocial.org/read-blog/27296?mode=day
mexican mail order pharmacies: п»їbest mexican online pharmacies – mexican rx online
https://easyrxcanada.com/# safe online pharmacies in canada
canadian compounding pharmacy canadianpharmacy com best rated canadian pharmacy
https://easyrxindia.shop/# best india pharmacy
canadian online drugstore canadian pharmacy online canadian pharmacy cheap
top online pharmacy india: online pharmacy india – buy prescription drugs from india
Добрый день!
Диплом любой специальности
blog.nataraj.ru/~/Interest
Добрый день!
Пошаговая инструкция по официальной покупке диплома о высшем образовании
phonotope.net/topics/archives/000052
Привет!
Купить документ о получении высшего образования вы имеете возможность в нашей компании в Москве.
bestallorder.nnov.org/blog/predpochitaete_kupit_originalnyy_diplom_
I just could not go away your site before suggesting that I extremely enjoyed the usual info an individual provide for your guests? Is gonna be again ceaselessly in order to check up on new posts