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

9,733 Responses

  1. 12 Companies Leading The Way In Land Rover Discovery 3 Key Fob Replacement
    How to program Land rover discovery 2 key fob

  2. qgzwxsqvu表示:

    The iconic Hanna-Barbera animation and wit lends itself well to land-based and online slots. In fact, US slot giants WMS have had a tie-up with the show’s producers for a few years. The first The Flintstones land-based slot came out in 2014, and was featured exclusively at the Borgata Casino in Atlantic City. Shipping: Whether you want to buy a few used slot machines for your home or need to stock a casino, Slot Machines Unlimited can help. We also carry machine parts, casino chairs, slot machine stands, signage, and more. When you purchase from Slot Machines Unlimited, we strive to make sure your order meets your needs. The slot machines purchased on our website come with a limited warranty and lifetime tech support. Looking for jquery, css slot machine or slot machine html5? We’ve got you covered. Buy or Rent our slot machine at affordable price in the market. Go to More Information: aistechnolabs jquery-slot-machine
    https://beauuvxx752084.bloggosite.com/35122776/best-rtp-slot-machines
    Reveal other websites that your audience is interested in. See the list of domains users are browsing next. Lotteryextreme’s audience also visits national-lottery, followed by lottonumbers, and lottomatic.org. “I lost it,” Brown said in the release. “I started crying immediately, running around the store, breakdancing. Whatever you want to call it, I was doing it. All I could think about was that I could do everything I finally wanted to do.” The latest is Gregory Even of Jesup who won a jackpot prize of $62,388 after purchasing his winning ticket at Casey’s in Gilbertville. Even claimed his winnings last Friday. The Extreme Green Progressive jackpot starts at $20,000 and increases with each ticket sold statewide until it is won.

  3. Профессиональный сервисный центр по ремонту фото техники от зеркальных до цифровых фотоаппаратов.
    Мы предлагаем: ремонт фотоаппарата
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  4. 오피表示:

    Your post is a valuable resource for us all.오피

  5. Considerably, the article is in reality the greatest on this noteworthy topic. I agree with your conclusions and will eagerly watch forward to your next updates. Saying cheers will not just be sufficient, for the wonderful clarity in your writing. I will immediately grab your rss feed to stay privy of any updates!

  6. What i don’t realize is if truth be told how you are now not really a lot more neatly-appreciated than you may be right now. You’re very intelligent. You know thus considerably in relation to this matter, made me in my opinion consider it from so many numerous angles. Its like men and women aren’t fascinated unless it?s something to do with Girl gaga! Your personal stuffs excellent. Always care for it up!

  7. Abrahamwarne表示:

    illegal online pharmacy: offshore pharmacy no prescription – lorazepam online pharmacy

  8. Tips For Having A Fun Hen Party In Dublin 하이오피 유흥사이트

  9. eve thai表示:

    Attractive component to content. I just stumbled upon your web site and in accession capital to say that I acquire actually loved account your blog posts. Anyway I will be subscribing to your augment and even I fulfillment you access persistently fast.

  10. Why We Are In Love With Replacement Key For Skoda Fabia (And You Should Too!) key Fob repair Near Me

  11. Mary表示:

    What’s The Job Market For Car Key Repair Shop Near Me Professionals?
    car key repair shop near me (Mary)

  12. Thank you for another fantastic blog. Where else might one get that sort of knowledge written in such a perfect way? I actually have a presentation that i’m presently acting on, and i are yearning for such info instead.

  13. Howdy! I know this is kinda off topic but I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My website addresses a lot of the same topics as yours and I believe we could greatly benefit from each other. If you are interested feel free to shoot me an e-mail. I look forward to hearing from you! Superb blog by the way!

  14. Ypbuae表示:

    order voveran online – order isosorbide 40mg pills buy nimodipine for sale

  15. Если вы искали где отремонтировать сломаную технику, обратите внимание – выездной ремонт бытовой техники в челябинске

  16. Is Technology Making ADHD Diagnosis Near Me Better Or Worse?

    where To get adhd diagnosed

  17. Mesothelioma lawyers specialize in asbestos litigation, which includes
    lawsuits and trust fund claims. They must be aware of the complex laws of the state and
    national legal requirements to effectively handle these types of
    claims.

  18. I adore your wordpress design, exactly where do you obtain it from?

  19. Hiya, I am really glad I’ve found this info. Today bloggers publish only about gossips and web and this is really frustrating. A good web site with interesting content, that is what I need. Thanks for keeping this web-site, I’ll be visiting it. Do you do newsletters? Can not find it.

  20. The Most Worst Nightmare About Buy Anal Sex Toys Be Realized kinky anal toys (http://ybsangga.innobox.co.Kr/)

  21. Chun表示:

    The Most Hilarious Complaints We’ve Seen About Freestanding Electric Fireplace Heater free standing electric fireplace stoves (Chun)

  22. Отличный сайт! Всем рекомендую!портрет на холсте в Тюмени

  23. 10 Misconceptions Your Boss Has Regarding Rollators Walkers With Seat Rollators with seat

  24. Excellent post. I used to be checking continuously this blog and I am inspired! Very useful information particularly the closing phase 🙂 I care for such info much. I used to be looking for this particular information for a long time. Thanks and good luck.

  25. auhyypelx表示:

    Ótimo O preço de Micro Bitcoin hoje é US$0.001075, com um volume de negociações nas últimas 24 horas de $N+0.00% nas últimas 24 horas.MB tem uma oferta máxima de 21 M MB. NovaDAX Brasil Pagamentos Ltda, a empresa constituída no Brasil com NIRE 35235369291 e endereço Avenida Paulista, 1842, Torre Norte Conj 155 Sala 10 – CEP 01310-945 – São Paulo, SP, é permitida de atuar como correspondentes de instituições financeiras sob o CNPJ 31.745.082 0001-27 emitido pela Receita Federal do Brasil. Acompanhe a cotação do bitcoin, do ethereum e de diversas outras criptomoedas em tempo real. Bitcoin passa de US$ 66 mil e alcança maior valor em dois anos em trilha para máxima histórica Último recorde foi em 2021 com mais de US$ 68 mil
    https://snoopydirectory.com/listings341630/pwc-bitcoin
    Certamente já ouviu falar em bitcoin, mas é bastante provável que não perceba como obter este tipo de moeda. Na verdade, a bitcoin é apenas uma das criptomoedas a circular no mundo virtual. O facto de ter sido a primeira faz com que seja a mais famosa, mas a forma como estes ativos funcionam é a mesma. de scripts e ideias personalizados compartilhados por nossos usuários. Ao definir uma nova corretora para comprar tokens, os usuários iniciantes podem começar no mercado à vista para, com o tempo, ganharem experiência e explorarem outros mecanismos e funções disponíveis nas plataformas. A criptomoeda é uma moeda digital descentralizada que opera em tecnologia de blockchain. As suas principais funcionalidades incluem transparência, transações sem fronteiras e imutabilidade. Algumas das criptomoedas mais populares, por capitalização do mercado, incluem Bitcoin, Ethereum e Tether, que podem ser transacionadas na OKX.

  26. Are You Responsible For An Depression Treatment And Recovery Budget?
    10 Wonderful Ways To Spend Your Money depression treatment residential

  27. Wcrfonert表示:

    I know there are special issues with your surgery, but I have read discussions on the Low Carb Friends board in the section among people who have had WLS.
    shopping process. | From the bed you can buy your lexapro and weight gain they are right for you.
    However, many disease conditions can result in elevation of blood pressure, and such cases are referred to as secondary hypertension.

  28. J’apprécie cette diapositive toutefois j’en ai auparavant vu de semblable de meilleures qualité supérieure

  29. PH POP CASINO表示:

    I want to to thank you for this good read!! I definitely enjoyed every bit of it. I have got you saved as a favorite to look at new stuff you post…

  30. Use the promo code when registering on 1win and get a 100% bonus on your first deposit.

發佈留言

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