AngularJS – 基本介紹篇
看完上一篇有關AngularJS的文章之後,如果你已經產生對他的興趣,接下來我們就跟著Google規劃的課程來學習,其實在AngularJS的官方網頁上,本來就有這方面的視訊教學(當然是英文的囉!),馬老師這邊只是做到整理、翻譯和提出我的一些想法,讓想要學習他的人可以更方便,官方視訊總共分成五個等級,每個等級又分成不同章節,章節結束後還都會有模擬測驗,真的推薦大家可以去看看喔!
首先檢視一下要學習AngularJS的一些背景條件:
必須了解的部分指的是技術領域,最好能懂的部分是指開發時的觀念
至於選擇AngularJS的理由有以下幾點:
- 幫助你組織Javascript
- 快速幫你建構動態網站
- 可以跟jQuery合作愉快
- 便於測試
接下來官方教學以ng-controller為案例,教導AngularJS是如何去呼叫函數的,不過這部分在1.3以上的版本已經不是這樣使用了要特別注意!
以下就針對這個案例進行程式的示範,在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)。
上述的程式可以撰寫在一個JS檔案中,讓網頁將該檔案引用。
接下來在HTML標籤中加入ng-app=”Application Name”後,讓網頁在載入的時候就會自動運行該模組(Module)。
接下來開始介紹表達式,不過這個在上一篇案例當中我們已經有使用過了,相信大家也很容易能夠了解,也建議大家去參考視訊中提到的網頁,裡面有更多有關於表達式的說明。
※以上截圖部分為AngularJS官方教學視訊。
My programmer is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the expenses. But he’s tryiong none the less. I’ve been using Movable-type on a variety of websites for about a year and am worried about switching to another platform. I have heard good things about blogengine.net. Is there a way I can transfer all my wordpress posts into it? Any help would be really appreciated!
Repairs To Upvc Windows Tools To Improve Your Everyday LifeThe Only Repairs To Upvc
Windows Technique Every Person Needs To Learn repairs to upvc
windows (Kayleigh)
15 Weird Hobbies That Will Make You Smarter At Full Size Sleeper Sofa sofas sleeper sofas;
Consuelo,
Testing For ADHD Tools To Ease Your Daily Life Testing For
ADHD Technique Every Person Needs To Know Test For Adult Adhd
You’ll Never Guess This Bifold Door Repairs Near Me’s Tricks bifold door Repairs near me
Five Killer Quora Answers To Multi Fuel Stove Surround Ideas multi fuel stove surround ideas
The 9 Things Your Parents Taught You About Sectional Sofa L Shaped
sectional sofa l shaped, Janette,
What’s The Job Market For ADHD Without Medication Professionals
Like? Adhd without medication
5 Killer Quora Answers On Bi Folding Door Repair Near Me bi
folding door repair near me (https://www.How2youtube.com/g/bbs/board.php?bo_table=free&wr_id=1589098)
How Mesothelioma Law Has Changed My Life The Better mesothelioma Lawyers
A Proficient Rant Concerning Auto Accident Lawyer auto
accident attorneys in houston [Tisha]
Would you be all in favour of exchanging hyperlinks?
hello!,I like your writing very a lot! share we keep in touch more about your article on AOL? I need an expert on this area to solve my problem. May be that is you! Having a look forward to peer you.
See What Folding Treadmill Incline Tricks The Celebs Are Using Folding Treadmill Incline
You’ll Never Guess This Mobility Scooter Usa’s Tricks mobility scooter usa
Five Killer Quora Answers On Repair Bifold Door Top
Roller repair bifold door top roller
15 Things To Give The Private ADHD Assessments Lover In Your Life private Adhd assessment gloucestershire
Guide To Autowatch Ghost Installers Near Me: The Intermediate
Guide Towards Autowatch Ghost Installers Near Me Autowatch Ghost Installers Near Me
20 Up-Andcomers To Watch The Sofas L Shape Industry Leather Sofas l shape
It’s my belief that mesothelioma is usually the most lethal cancer. It has unusual features. The more I actually look at it the harder I am assured it does not react like a real solid cells cancer. In the event mesothelioma is actually a rogue viral infection, so there is the potential for developing a vaccine as well as offering vaccination for asbestos open people who are open to high risk with developing future asbestos associated malignancies. Thanks for revealing your ideas for this important ailment.
What Is Online Mental Health Assessment? How To
Use It comprehensive mental Health assessment Online
Bmw 1 Series Key Tools To Enhance Your Day-To-Day Life nearby
The Reason Why Foldable Treadmill With Incline Is Everyone’s Obsession In 2023
What Do treadmill Incline numbers mean
10 Apps To Help You Manage Your Mesothelioma Legal mesothelioma lawsuit (https://r2tbiohospital.com/bbs/board.php?bo_table=free&wr_id=1094145)
Why People Don’t Care About Volvo Keys Volvo v40 key programming
Are You Responsible For A Hyundai I20 Replacement Key Budget?
12 Top Ways To Spend Your Money hyundai i20 car key replacement
How To Explain Situs Togel Terpercaya To Your Grandparents Situs toto
I?m not certain where you’re getting your info, but good topic. I needs to spend a while finding out more or figuring out more. Thank you for great information I used to be searching for this information for my mission.
I?ve read some good stuff here. Definitely worth bookmarking for revisiting. I wonder how much effort you put to create such a great informative site.
20 Questions You Should Always Be Asking About Couch Before
Buying It couches for small living rooms (Gertrude)