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清單。
https://indiapharmacy.shop/# indian pharmacies safe
https://indiapharmacy.shop/# Online medicine home delivery
cheap ed medicine
[u][b] Привет, друзья![/b][/u]
Купить документ института
[url=http://karkadan.ru/users/77829/]karkadan.ru/users/77829[/url]
[url=http://telegra.ph/besplatnoe-obuchenie-v-vuze-07-24/]telegra.ph/besplatnoe-obuchenie-v-vuze-07-24[/url]
[url=http://yur-dom.ru/communication/forum/messages/forum3/message290/333-bystroe-poluchenie-diploma-onlayn?result=new#message290/]yur-dom.ru/communication/forum/messages/forum3/message290/333-bystroe-poluchenie-diploma-onlayn?result=new#message290[/url]
[url=http://allonlinesport.ru/ekspress-dostavka-diplomov-po-vsey-strane/]allonlinesport.ru/ekspress-dostavka-diplomov-po-vsey-strane[/url]
[url=http://telegra.ph/kakie-dokumenty-na-postuplenie-v-vuz-07-24/]telegra.ph/kakie-dokumenty-na-postuplenie-v-vuz-07-24[/url]
Добрый день!
Диплом юриста
koxma.4adm.ru/viewforum.php?f=296
Привет, друзья!
Купить диплом о среднем полном образовании, в чем подвох и как избежать обмана?
diploms-man.ru/diplom-tehnikuma
Рады оказаться полезными!.
mexican pharmaceuticals online: Purple pharmacy online ordering – medicine in mexico pharmacies
Привет!
Официальная покупка аттестата о среднем образовании в Москве и других городах
arusak-diploms-srednee.ru/svidetelstvo-o-brake
Добрый день!
Купить документ о получении высшего образования можно в нашей компании.
diploms-rushka.ru
https://indiapharmacy.shop/# india pharmacy
low cost ed meds online
http://edpillpharmacy.store/# cheapest online ed meds
low cost ed meds
онлайн гадание бесплатно самое правдивое гадание бесплатное
Привет!
Купить диплом магистра оказалось возможно, быстрое обучение и диплом на руки
rushkas-diploms.ru/kupit-diplom-krasnodar
http://edpillpharmacy.store/# low cost ed medication
top 10 online pharmacy in india: indian pharmacy – india pharmacy
https://edpillpharmacy.store/# order ed pills online
There are definitely a whole lot of particulars like that to take into consideration. That is a great point to carry up. I offer the thoughts above as common inspiration but clearly there are questions like the one you deliver up the place a very powerful thing can be working in trustworthy good faith. I don?t know if best practices have emerged around issues like that, however I’m sure that your job is clearly identified as a fair game. Each boys and girls really feel the impression of just a moment?s pleasure, for the remainder of their lives.
Привет!
Мы изготавливаем дипломы любых профессий по доступным ценам.
rushkadiplomik.ru
Здравствуйте!
Как оказалось, купить диплом кандидата наук не так уж и сложно
arusak-diploms-srednee.ru/kupit-diplom-medicinskogo-uchilishha
how to get ed meds online: Cheap ED pills online – ed online meds
Добрый день!
Приобретение диплома ПТУ с сокращенной программой обучения в Москве
diplomman.ru/kupit-diplom-ekaterinburg
Рады оказать помощь!.
http://edpillpharmacy.store/# ed doctor online
online ed medication
Привет!
Вопросы и ответы: можно ли быстро купить диплом старого образца?
mandiplomikx.ru/kupit-diplom-novosibirsk
Всегда вам поможем!.
https://mexicopharmacy.win/# п»їbest mexican online pharmacies
low cost ed meds
This is really interesting, You’re a very skilled blogger. I have joined your rss feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!
Здравствуйте!
Приобрести диплом любого университета.
diploms-man.ru/kupit-diplom-ekaterinburg
https://mexicopharmacy.win/# mexico pharmacies prescription drugs
ed online treatment
http://edpillpharmacy.store/# best ed meds online
best online ed treatment
ed online prescription: Cheapest online ED treatment – online ed meds
Привет, друзья!
Как приобрести диплом о среднем образовании в Москве и других городах
landik-diploms-srednee.ru/kupit-diplom-v-ekaterinburge
Привет, друзья!
Мы можем предложить дипломы любых профессий по невысоким тарифам.
rushkas-diplomxx.ru/kupit-diplom-medsestry