AngularJS – Tab 介紹篇
為了方便文章閱讀,本篇將Tab翻譯成頁籤
這個案例的複雜度會比較前面高一些,因為它不僅僅是使用我們一直提到的AngularJS,為了要製作頁面上面的一些互動效果,還加入了Bootstrape這個通常被用來當RWD的框架,不過也僅僅是套用了幾個類別,所以大家也不用太擔心,接下來我們先看一下這個案例最後希望要達成的效果頁面。
在看過了目標頁面後,我們先來了解一下需要怎麼樣架構我們的HTML,首先是CSS和Javascript的引入,分別是AngularJS、jQuery、Bootstrap CSS以及Javascript:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> <script src="https://code.jquery.com/jquery.min.js"></script> <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
在HTML文件中,必須有項目清單標籤ul、li,而在ul標籤中需套用nav nav-pills這兩個css類別,這兩個類別是由Bootstrape的css所提供的,li標籤是包覆著超連結的a標籤,下圖案例是希望可以產生三個頁籤。

在a標籤中加入ng-click=”tab = 1″、ng-click=”tab = 2″、ng-click=”tab = 3″去設定當使用者按下連結後tab變數會隨著變化,另外為了方便觀察是否成功,在頁面上利用表達式將tab變數顯示出來。

若一切順利,在我們按下不同的頁籤連結時,畫面上應該會有數字上面的變化。


接下來開始製作點選頁籤後的內容頁面,同樣的內容頁面也應該有三個才對,在HTML中產生三個div,其中套用Bootstrape所提供的CSS panel類別,div的內容部分可依照需求置入。

在div中利用ng-show去判斷tab變數的值來切換顯示。

完成後,在我們點選不同的連結時,內容的部分也應該會隨著變動。

接下來我們在section標籤中設定ng-init=”tab=1″的屬性來決定tab變數的初始值。

接下來在li內新增ng-class的屬性,依tab變數的值來切換active的CSS屬性(該屬性由Bootstrape提供樣式),其中三個連續的等號是判斷該變數與值完全相同的意思。

這個動作的目的是希望當網友點選之後,可以如下圖所示,清楚的標示目前頁面上所顯示的是第幾個項目。

到目前為止,大概就完成了我們希望呈現的頁籤效果,大家可以透過JS Bin來測試看看到目前為止的程式碼。
<!DOCTYPE html> <html ng-app> <head> <meta name="description" content="AngularJS Tabs Example 1"> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> <script src="//code.jquery.com/jquery.min.js"></script> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <meta charset="utf-8"> <title>AngularJS Tabs Example 1</title> </head> <body> <section ng-init="tab=1"> <ul class="nav nav-pills"> <li ng-class="{ active: tab===1 }"> <a href="" ng-click="tab=1">滑鼠墊</a> </li> <li ng-class="{ active: tab===2 }"> <a href="" ng-click="tab=2">馬克杯</a> </li> <li ng-class="{ active: tab===3 }"> <a href="" ng-click="tab=3">杯墊</a> </li> </ul> <div class="panel" ng-show="tab===1"> <h4>馬老師雲端研究室 滑鼠墊</h4> <p>產品介紹...</p> </div> <div class="panel" ng-show="tab===2"> <h4>馬老師雲端研究室 馬克杯</h4> <p>產品介紹...</p> </div> <div class="panel" ng-show="tab===3"> <h4>馬老師雲端研究室 杯墊</h4> <p>產品介紹...</p> </div> </section> </body> </html>
在看完了上面的案例之後,我們可以觀察到程式邏輯判斷的部分都是直接撰寫在HTML頁面上,那如果我們要把邏輯判斷的部分從HTML拆開寫到Javascript檔又應該要如何處理呢?首先,不用說的當然是必須要有應用程式的建立以及控制器囉!下圖中我們開始新增控制器,並且在section標籤中,輸入ng-controller=”panelController as panel”的屬性,相信在看了前幾篇教學的同學們對於這樣的項目是再熟悉不過了!接下來在控制器中,決定tab變數的初始值,就可以把原來的ng-init屬性刪除了。

在ng-click後去執行控制器中的selectTab函數,並且針對該函數帶入不同的值,利用帶入的值來改變tab變數值。

在ng-click後去執行控制器中的isSelected函數,也帶出不同的值給函數,讓函數可以回傳tab===1或2、3這樣的內容給ng-show使用。

這樣一來我們邏輯判斷的部分就會和網頁內容有所區隔,大家也可以透過JS Bin來測試這樣的程式結構。
<!DOCTYPE html> <html ng-app="store"> <head> <meta name="description" content="AngularJS Tabs Example 2"> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> <script src="//code.jquery.com/jquery.min.js"></script> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <meta charset="utf-8"> <title>AngularJS Tabs Example 2</title> </head> <body> <section ng-controller="PanelController as panel"> <ul class="nav nav-pills"> <li ng-class="{ active: panel.isSelected(1) }"> <a href="" ng-click="panel.selectTab(1)">滑鼠墊</a> </li> <li ng-class="{ active: panel.isSelected(2) }"> <a href="" ng-click="panel.selectTab(2)">馬克杯</a> </li> <li ng-class="{ active: panel.isSelected(3) }"> <a href="" ng-click="panel.selectTab(3)">杯墊</a> </li> </ul> <div class="panel" ng-show="panel.isSelected(1)"> <h4>馬老師雲端研究室 滑鼠墊</h4> <p>產品介紹...</p> </div> <div class="panel" ng-show="panel.isSelected(2)"> <h4>馬老師雲端研究室 馬克杯</h4> <p>產品介紹...</p> </div> <div class="panel" ng-show="panel.isSelected(3)"> <h4>馬老師雲端研究室 杯墊</h4> <p>產品介紹...</p> </div> </section> </body> </html>
(function(){ var app = angular.module('store', []); app.controller('PanelController', function(){ this.tab = 1; this.selectTab = function(setTab){ this.tab = setTab; }; this.isSelected = function(checkTab){ return this.tab === checkTab; }; }); })();
US Bitcoin reserve prompts $370 million in ETF outflows: Farside
k8vip k8 th? dam k8 bet
https://88betviet.pro/# 88bet
https://88betviet.pro/# 88bet
k8vip: k8vip – link vao k8
https://88betviet.pro/# 188bet 88bet
https://www.ultimatejobs.com/smtp/pages/1xbet_today_promo_code_bonus_up_to_130.html
https://ontariobev.net/wp-content/pgs/?1xbet_today_promo_code_bonus_up_to_130.html
Whether you’re an experienced trader or a beginner, SimpleSwap makes crypto trading simple and efficient.
https://simpleswap-io.net/
https://alo789.auction/# alo 789
https://88betviet.pro/# 88bet slot
посетить веб-сайт
бизнес по переработки отходов
можно проверить ЗДЕСЬ
бизнес по переработки отходов
нажмите здесь
готовый бизнес по переработке пластика
Elon Musk’s X eyeing capital raise at $44B valuation: Report
нажмите здесь
бизнес по переработки
подробнее
готовый бизнес
нажмите здесь
завод по переработке пластика
Источник
оборудование для переработки пластиков
в этом разделе
бизнес по переработке мусора
подробнее
завод по переработке пластика
посмотреть на этом сайте
бизнес по переработки отходов
мастбет http://ongame.forum24.ru/?1-18-0-00001219-000-0-0-1742360461/ .
игра 1вин http://taksafonchik.borda.ru/?1-14-0-00002041-000-0-0/ .
1 win pro http://belbeer.borda.ru/?1-6-0-00001555-000-0-0-1742473542/ .
A librarian ran off with a yacht captain in the summer of 1968. It was the start of an incredible love story
metamask
The first time Beverly Carriveau saw Bob Parsons, she felt like a “thunderbolt” passed between them.
“This man stepped out of a taxi, and we both just stared at each other,” Beverly tells CNN Travel today. “You have to remember, this is the ‘60s. Girls didn’t stare at men. But it was a thunderbolt.”
It was June 1968. Beverly was a 23-year-old Canadian university librarian on vacation in Mazatlan, Mexico, with a good friend in tow.
Beverly had arrived in Mazatlan that morning. She’d been blown away by the Pacific Ocean views, the colorful 19th-century buildings, the palm trees.
Now, Beverly was browsing the hotel gift store, admiring a pair of earrings, when she looked up and spotted the man getting out of the taxi. The gift shop was facing the parking lot, and there he was.
“I was riveted,” says Beverly. “He was tall, handsome…”
Eventually, Beverly tore away her gaze, bought the earrings and dashed out of the store.
“We locked eyes so long, I was embarrassed,” she says.
No words had passed between them. They hadn’t even smiled at each other. But Beverly felt like she’d revealed something of herself. She felt like something had happened, but she couldn’t describe it.
Beverly rushed to meet her friend, still feeling flustered. Over dinner in the hotel restaurant, Beverly confided in her friend about the “thunderbolt” moment.
“I told my girlfriend, ‘Something just happened to me. I stared at this man, and I couldn’t help myself.’”
Then, the server approached Beverly’s table.
“He said, ‘I have some wine for you, from a man over there.’”
The waiter was holding a bottle of white wine, indicating at the bar, which was packed with people.
As a rule, Beverly avoided accepting drinks from men in bars. She never felt especially comfortable with the power dynamic — plus, she had a long-term partner back in Canada.
“I had a serious boyfriend at home and thought my life was on course,” she says.
Xavier completes thrilling comeback, Mount St. Mary’s advances as men’s First Four comes to a close
changenow
Wednesday saw the men’s First Four come to a close which means only one thing: the 64-team bracket is officially set following No. 11 Xavier’s thrilling come from behind win over No. 11 Texas and No. 16 Mount St. Mary’s victory over No. 16 American in Dayton, Ohio.
The Musketeers trailed by as many as 13 points, but their offense came alive in the second half behind guard Marcus Foster and forward Zach Freemantle to down the Longhorns 86-80.
The senior Foster scored a team-high 22 points while Freemantle, on his way to 15 points, threw down a dunk with a second left to seal the comeback win and ignite the fans at UD Arena, which is just over 50 miles away from campus in Cincinnati, Ohio.
With just under four minutes remaining, Xavier went on an 8-2 run to take a 78-74 lead, their first since the early going of the first half.
Musketeers head coach Sean Miller crowned Wednesday’s game as “one of the best” he’s been a part of.
“I thought we were dead in the water two different times,” Miller told the truTV broadcast after the game. “But that’s the one thing about our team — the resiliency of our group has always won out for us. Just when you thought we weren’t gonna make the tournament, we kept winning. Even in this game, just when you’re like, ‘It’s not gonna work out,’ we have a funny way of staying with it.”
The Longhorns did not go down without a fight as guard Tre Johnson scored a game-high 23 points in the loss.
Xavier will face No. 6 Illinois in the first round on Friday at the Fiserv Forum in Milwaukee.
ссылка на сайт
переработка пластиков
https://neokomsomol.kz/# Соревнуйтесь с друзьями на игровых автоматах.
The world’s largest architectural model captures New York City in the ’90s
aerodrome finance
The Empire State building stands approximately 15 inches tall, whereas the Statue of Liberty measures at just under two inches without its base. At this scale, even ants would be too big to represent people in the streets below.
These lifelike miniatures of iconic landmarks can be found on the Panorama — which, at 9,335 square feet, is the largest model of New York City, meticulously hand-built at a scale of 1:1,200. The sprawling model sits in its own room at the Queens Museum, where it was first installed in the 1960s, softly rotating between day and night lighting as visitors on glass walkways are given a bird’s eye view of all five boroughs of the city.
To mark the model’s 60th anniversary, which was celebrated last year, the museum has published a new book offering a behind-the-scenes look at how the Panorama was made. Original footage of the last major update to the model, completed in 1992, has also gone on show at the museum as part of a 12-minute video that features interviews with some of the renovators.
The Queens Museum’s assistant director of archives and collections, Lynn Maliszewski, who took CNN on a visit of the Panorama in early March, said she hopes the book and video will help to draw more visitors and attention to the copious amount of labor — over 100 full-time workers, from July 1961 to April 1964 — that went into building the model.
“Sometimes when I walk in here, I get goosebumps, because this is so representative of dreams and hopes and family and struggle and despair and excitement… every piece of the spectrum of human emotion is here (in New York) happening at the same time,” said Maliszewski. “It shows us things that you can’t get when you’re on the ground.”
Original purpose
The Panorama was originally built for the 1964 New York World’s Fair, then the largest international exhibition in the US, aimed at spotlighting the city’s innovation. The fair was overseen by Robert Moses, the influential and notorious urban planner whose highway projects displaced hundreds of thousands New Yorkers. When Moses commissioned the Panorama, which had parts that could be removed and redesigned to determine new traffic patterns and neighborhood designs, he saw an opportunity to use it as a city planning tool.
Originally built and revised with a margin of error under 1%, the model was updated multiple times before the 1990s, though it is now frozen in time. According to Maliszewski, it cost over $672,000 to make in 1964 ($6.8 million in today’s money) and nearly $2 million (about $4.5 million today) was spent when it was last revised in 1992.