AngularJS – 基本介紹篇

看完上一篇有關AngularJS的文章之後,如果你已經產生對他的興趣,接下來我們就跟著Google規劃的課程來學習,其實在AngularJS的官方網頁上,本來就有這方面的視訊教學(當然是英文的囉!),馬老師這邊只是做到整理、翻譯和提出我的一些想法,讓想要學習他的人可以更方便,官方視訊總共分成五個等級,每個等級又分成不同章節,章節結束後還都會有模擬測驗,真的推薦大家可以去看看喔!

首先檢視一下要學習AngularJS的一些背景條件:

必須要了解

  • HTML、CSS
  • Javascript

最好能懂

不是那麼重要的

  • jQuery
  • Ruby
  • Rails
  • Python
  • PHP
  • Database

必須了解的部分指的是技術領域,最好能懂的部分是指開發時的觀念

AngularJS Part1 Slide1

至於選擇AngularJS的理由有以下幾點:

  • 幫助你組織Javascript
  • 快速幫你建構動態網站
  • 可以跟jQuery合作愉快
  • 便於測試
AngularJS Part1 Slide2

接下來官方教學以ng-controller為案例,教導AngularJS是如何去呼叫函數的,不過這部分在1.3以上的版本已經不是這樣使用了要特別注意!

AngularJS Part1 Slide3

以下就針對這個案例進行程式的示範,在1.2(含)以前的AngularJS可以這樣來操作ng-controller:(在JS Bin上測試

<!doctype html>
<html ng-app>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<meta charset="UTF-8">
<title>controllerExample</title>
<script>
  function myFn() {
    alert("歡迎光臨馬老師雲端研究室");
  }
</script>
</head>
<body ng-controller="myFn">
</body>
</html>

但在1.3(含)之後的AngularJS需要這樣來操作ng-controller:(在JS Bin上測試)

<!doctype html>
<html ng-app="controllerExample">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="UTF-8">
<title>controllerExample AngularJS 1.3.2</title>
<script>
angular.module('controllerExample', [])
.controller('myFn', function (){
    alert("歡迎光臨馬老師雲端研究室");
});
</script>
</head>
<body ng-controller="myFn">
</body>
</html>

根據上面的案例,來介紹利用AngularJS開發網頁時的流程和方式:

首先我們可以先建立一個模組(Module),在模組內會包含AngularJS的函式名稱、應用程式名稱(Application Name)和相關函式庫(Dependencies)。

AngularJS Part1 Slide4

上述的程式可以撰寫在一個JS檔案中,讓網頁將該檔案引用。

AngularJS Part1 Slide5

接下來在HTML標籤中加入ng-app=”Application Name”後,讓網頁在載入的時候就會自動運行該模組(Module)。

AngularJS Part1 Slide6

接下來開始介紹表達式,不過這個在上一篇案例當中我們已經有使用過了,相信大家也很容易能夠了解,也建議大家去參考視訊中提到的網頁,裡面有更多有關於表達式的說明。

AngularJS Part1 Slide7

※以上截圖部分為AngularJS官方教學視訊

You may also like...

16,356 Responses

  1. BrettTIT表示:

    Generic Viagra for sale: FastPillsForMen – buy viagra here

  2. We carried out two such missions, which helped us identify many issues that did not work (and many who did).

  3. Stories could also be customized and emailed on a day by day, weekly or month-to-month basis.

  4. In January 2023, the Halton Group took full possession of a South Whales based damper and hearth damper designer, Flamgard Calidar.

  5. See What Lightweight Motorized Folding Wheelchair Tricks The Celebs Are Utilizing lightweight motorized folding wheelchair

  6. Savage, Phil (October 14, 2014).

  7. 14 Savvy Ways To Spend The Leftover Attorney For Mesothelioma Budget Mesothelioma lawyers

  8. Are You Making The Most Of Your Mesothelioma Asbestos Claims?

    Mesothelioma lawyer

  9. Barrybib表示:

    viagra canada: FastPillsForMen.com – Order Viagra 50 mg online

  10. Saddle up and experience the magic – because right here, each meal is a journey, and each evening is a step again in time.

  11. Soon after it emerged that Graziano Di Prima had been sacked for ‘kicking’ his accomplice Love Island star Zara McDermott.

  12. Donaldabula表示:

    Generic Tadalafil 20mg price Max Pills For Men Generic Cialis without a doctor prescription

  13. Charlesbot表示:

    http://maxpillsformen.com/# Cialis 20mg price

  14. Each type of health insurance plan, be it a managed-care or payment-for-service plan, has other ways of dealing with each different form of state of affairs.

  15. RogerFaf表示:

    http://fastpillsformen.com/# Buy Viagra online cheap

  16. скорая наркологическая помощь на дому в москве скорая наркологическая помощь на дому в москве .

  17. как вызвать наркологическую скорую помощь в москве http://www.justforum.bestforums.org/viewtopic.php?f=26&t=4785/ .

  18. скорая наркологическая помощь на дому в москве скорая наркологическая помощь на дому в москве .

  19. вызов нарколога на дом частная скорая помощь вызов нарколога на дом частная скорая помощь .

  20. вызвать наркологическую помощь [url=http://honey.ukrbb.net/viewtopic.php?f=45&t=16764/]вызвать наркологическую помощь[/url] .

  21. срочная наркологическая помощь [url=https://golosa.ukrbb.net/viewtopic.php?f=3&t=7485]срочная наркологическая помощь[/url] .

  22. BrettTIT表示:

    Buy Viagra online cheap: FastPillsForMen – generic sildenafil

  23. неотложная наркологическая помощь в москве неотложная наркологическая помощь в москве .

  24. vwlmxrhnl表示:

    So how has this transformed into a form of self-care for the skincare obsessed? I turned to the experts to give me the breakdown of how to gua sha the right way and how to lean into its benefits. Consider this your gua sha 101 crash course. Chiu noted that slow strokes with medium pressure are the most effective way to see results. Too hard and fast can result in “sha” or red marks. Chiu noted that slow strokes with medium pressure are the most effective way to see results. Too hard and fast can result in “sha” or red marks. Do not use gua sha directly on inflamed or open and picked skin. Instead, cover the area with a pimple patch before using. So, grab your gua sha, a serum or sheet mask, and follow our step-by-step guide in collab with @allyoucanface on how to use By BEAUTY BAY’s Jade Gua Sha.
    https://one-directory.com/listings402696/hooded-eyeliner
    i really like this gel liner. it was my first time using a gel liner and i quickly fell in love with it and i heard good things about the brown shade ( because i tryed the black first) and i wanted to try out the brwon shade because the black worked so well 🙂 okay the forst time i opend the cap to look at the gel it looked a little light and once it was on my eye it was more dark then i thought and it looked more natural 🙂 plus i love how it comes with a brush to XD I’ve been an eyeliner devotee from the moment I was able to perfect the cat-eye look. I’ve spent years testing out the best eyeliners to craft the perfect matte black wing or even the occasional pop of color. Be patient! “If you are working with liquid and gel eyeliners make sure they are fully dry before curling your eyelashes, applying mascara, or any other eye products,” says Tricome. “There is nothing worse than applying eyeliner and having your eyelash curling take it off or accidentally smudging it.” You can also seek out eyeliners that are formulated to be long-wearing. “Purchasing waterproof eyeliner is key, these formulas are made to ensure your eyeliner stays on all day,” says Moore. “You can also tap an eyeshadow that matches the color of the liner on top of the liner to ‘set’ the look in place.”

  25. наркологическая скорая в москве [url=http://familyportal.forumrom.com/viewtopic.php?id=28624/]наркологическая скорая в москве[/url] .

  26. частная скорая наркологическая помощь [url=http://www.domsadremont.ukrbb.net/viewtopic.php?f=3&t=916]частная скорая наркологическая помощь[/url] .

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。