發表文章

目前顯示的是有「angularJS」標籤的文章

Angular使用筆記4_AngularJS(Angular1.x)_控制器(ng-controller)

圖片
  https://oscarvillarreal.com/2013/05/07/5-reasons-to-use-angularjs-in-the-corporate-app-world/ 在AngularJS 1.3版本之前早期控制器定義方法會用以下作法 <!DOCTYPE html> < html ng-app > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > 我的AngularJs練習3-1 </ title > < script type = "text/javascript" src = "./angular-1.6.4/angular.min.js" ></ script > </ head > < body > < div ng-controller = "contr" > {{ s }} < div ng-bind = "s" ></ div > </ div > < script type = "text/javascript" > function contr ( $scope ) { $scope . s = 'hello, welcome to angularjs world!' ; } </ script > </ body > </ html > 這是JS控制器用一個建構子手法,去實體化物件模板的寫法。方法本身即為物件的建構子。 參數...

Angular使用筆記3_AngularJS(Angular1.x)_雙向綁定(ng-model)、單向綁定(ng-bind)

圖片
  資料繫結(Data Binding) 是 AngularJS 框架在視圖(DOM 元素)與作用域之間建立的資料同步機制。 所謂「雙向綁定」,是指UI的操作能夠即時同步到作用域中,反之作用域中的資料修改也能夠即時回顯到介面中。作用域可以被視為一個容器,裡面有一些基於 key-value 的資料。 Data Binding in Classical Template Systems 大多數Template系統只會採用One-way Data Binding:將Template與模型元件合併成View。 合併完成後,Model或VIew相關區塊的變更都不會自動反映在檢視中。 更糟的是,使用者對檢視所做的任何變更,也不會反映在模型中。 換言之,開發人員必須撰寫程式碼,不斷同步檢視與模型,以及模型與檢視。 Data Binding in Angular Templates Angular Template則採用不同運作方式。 首先,範本(未經編譯的 HTML,以及任何額外的標記或指令)會在瀏覽器中編譯。 編譯步驟會產生即時檢視。檢視中的任何變更都會立即反映至模型,而模型中的任何變更也會傳遞至檢視。 Model是應用程式狀態的唯一源頭,大幅簡化了開發者的程式設計模型。 As If <! DOCTYPE html > < html > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > 我的AngularJs練習2 - 1 < /title> < /head> < body > < div > 用戶名 : < input type = "text" name = "uname" id = "uname" />< /div> < div >...

Angular使用筆記2_AngularJS(Angular1.x)簡單起手程式(ng-app、expression、ng-init)

圖片
https://oscarvillarreal.com/2013/05/07/5-reasons-to-use-angularjs-in-the-corporate-app-world/ 根據之前 blog篇章 已經會得知你到底該掌握的angular是哪一種了 在Angular.Js官方網站公告 https://angularjs.org/ ,AngularJS 的支援已於 2022 年 1 月正式終止。 不過部分早期系統為了穩定,仍可能會遇到這類JS框架。 初始建立一個簡易練習的Angular.Js的程式 可以先點Previois Versions 這邊可以點選公司團隊開發維運系統所指定的版本 https://code.angularjs.org/ 這邊挑選1.6.4版本來做小試身手,可點angular-1.6.4.zip把整包給下載下來後續做引入使用。 https://code.angularjs.org/1.6.4/ 每個版本點選doc就可以看到對應版本的api文檔 https://code.angularjs.org/1.6.4/docs/api https://code.angularjs.org/1.6.4/docs/guide/index 若透過CDN來導入的也可藉用其google官方CDN網址,自行更改版號來切換對應URL即可。 https://ajax.googleapis.com/ajax/libs/angularjs/ 1.6.4 /angular.min.js 這邊用vscode來開發 步驟 1:開啟整個專案資料夾 在 VS Code 按下 Ctrl + K,接著按 Ctrl + O,或使用選單 File → Open Folder。 步驟 2:開啟 HTML 檔案 從左側 Explorer 開啟 myangular1.html。 步驟 3:啟動 Live Server 點擊右下角 Go Live,或對 HTML 檔案按右鍵,選擇 Open with Live Server。 覽器會開啟類似: http://127.0.0.1:5500/myangular1.html 在上手AngularJs之前一些先備術語,稍微認識一下。 模型(Model): 也就是是AngularJs應用程式中用來呈現到頁面的數據,可以白話理解為Javascript物件...

Angular使用筆記1_Angular的歷史_Angular1跟Angular2比較

圖片
  Angular本身是由Google提出的一套base on MVC架構的 (可跟常見的後端程式語言PHP、.NET、NodeJS搭配開發) Web Application的開源JS Framework 主要特色在於可以對HTML透過指令方式做彈性延伸達成動態內容建構。 除了網頁應用也可以建構手機應用(跟Ionic 、RN搭配) 主要會在介紹到 Angular的歷史與版本演進 Angular1跟Angular2比較 Angular 開發工具介紹 Angular CLI Angular的使用場景 Angular的語法特點 Angular的歷史與版本演進 主要是在2009年由Misko Hevery 跟Adam Abrons兩個開發者設計出來的 Misko Hevery於2009年開始在Google工作 並且 於2012年由Google名義推出 Angular version 1.0 也就是AngularJS  A JavaScript MVW Framework   Extends HTML by adding attributes, tags, and expressions  Events Handling  Powerful Data Binding  Built-In Template Engine and Routing  Form Validations and Animations  Dependencies Injection etc. 於2016年9月則又釋出了Angular version 2.0  Modern, faster and highly scalable framework  One framework for web, mobile and desktop apps  Not an update to Angular1.x, but a complete rewrite  Written in Typescript  Simple and Expressive  Web components based architecture  Hierarchical Dependenc...