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...

20,759 Responses

  1. Guide To Bariatric Living Aids: The Intermediate Guide On Bariatric Living Aids bariatric living aids
    (goldberg-church.thoughtlanes.net)

  2. 10 . Pinterest Account To Be Following Buy Cayden Yorkshire Axel Terrier welpen kaufen​

  3. Jasonzitte表示:

    Their pet medication section is comprehensive.
    can i buy cipro without dr prescription
    Their vaccination services are quick and easy.

  4. Marlon表示:

    The Worst Advice We’ve Heard About Buy A Driving License For 500 Euros deutscher
    eu führerschein kaufen, Marlon,

  5. The 10 Scariest Things About Gotogel Link Alternatif gotogel Link alternatif

  6. Eleanore表示:

    See What 6ft Shipping Containers Tricks The Celebs Are Utilizing 6ft
    Shipping Containers (Eleanore)

  7. The Best Folding Treadmill UK Tricks To Transform Your
    Life best folding Treadmill uk

  8. What Experts On Used Pallets For Sale Want You To
    Know pallets Near me​

  9. Marcelo表示:

    How To Solve Issues Related To Wheelchair Foldable Ramp wheelchair bridge ramp [Marcelo]

  10. 66 lottery表示:

    I do agree with all the ideas you have presented in your post. They’re very convincing and will certainly work. Still, the posts are very short for starters. Could you please extend them a little from next time? Thanks for the post.

  11. WalterCherm表示:

    They have a fantastic range of supplements.
    https://cytotecpharm24.top/
    Global expertise that’s palpable with every service.

  12. Luigi表示:

    Why You Should Focus On Enhancing Robotic Vacuum Cleaner automated vacuum cleaner
    (Luigi)

  13. WalterCherm表示:

    The widest range of international brands under one roof.
    https://lisinoprilpharm24.top/
    They simplify the complexities of international prescriptions.

  14. Victorprima表示:

    Leading with integrity on the international front.
    gabapentin kick in time
    Delivering worldwide standards with every prescription.

  15. Diplomi_appn表示:

    где купить диплом в нижнем тагиле diploms-bests.ru .

  16. Victorprima表示:

    They have strong partnerships with pharmacies around the world.
    where can i get cipro price
    A reliable pharmacy in times of emergencies.

  17. 15 Best Power Tool Combo Kits Bloggers You Need To Follow best power Tool Combo kit

  18. Johnson表示:

    Buy Category B Driving License: A Simple Definition Comprar carta de condução categoria B
    (Johnson)

  19. The Most Successful Robot Cleaners Uk Gurus Can Do 3 Things best robot vacuum that mops

  20. 9 Things Your Parents Taught You About Leather Chesterfield Sofa Second Hand Leather Chesterfield Sofa Second Hand

  21. Jasonzitte表示:

    They have a great range of holistic health products.
    how to buy cheap cytotec online
    Their health awareness campaigns are so informative.

  22. Calvin表示:

    Who Is The World’s Top Expert On Buy Duxi Yorkshire Biewer?

    Clovis yorkshire terrier kaufen​ (Calvin)

  23. Upvc Doctor表示:

    17 Reasons Not To Beware Of Upvc Door Doctor Upvc Doctor

  24. I am really inspired together with your writing abilities and also with the structure for your blog. Is this a paid theme or did you customize it yourself? Anyway stay up the nice high quality writing, it?s uncommon to peer a nice blog like this one these days..

  25. WalterCherm表示:

    Every pharmacist here is a true professional.
    https://cipropharm24.top/
    They have a fantastic range of supplements.

  26. 66lottery表示:

    Thank you for another wonderful article. Where else could anybody get that kind of info in such an ideal way of writing? I have a presentation next week, and I’m on the look for such information.

  27. WalterCherm表示:

    Trust and reliability on a global scale.
    https://cytotecpharm24.top/
    Their global pharmacists’ network is commendable.

  28. Mark表示:

    You’ll Never Be Able To Figure Out This Psychiatry
    ADHD Near Me’s Tricks psychiatry adhd near me (Mark)

  29. Victorprima表示:

    Their prices are unbeatable!
    get clomid no prescription
    They have a fantastic range of supplements.

發佈回覆給「Marcelo」的留言 取消回覆

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