AngularJS
AngularJS是一款開源JavaScript函式庫,由Google維護,用來協助單一頁面應用程式運行的。它的目標是透過MVC模式(MVC)功能增強基於瀏覽器的應用,使開發和測試變得更加容易。 函式庫讀取包含附加自定義(標籤屬性)的HTML,遵從這些自定義屬性中的指令,並將頁面中的輸入或輸出與由JavaScript變量表示的模型綁定起來。這些JavaScript變量的值可以手工設置,或者從靜態或動態JSON資源中獲取。
AngularJS主要功能
- 雙向資料綁定
AngularJS directives
- ng-app Declares the root element of an AngularJS application, under which directives can be used to declare bindings and define behavior.
- ng-aria A module for accessibility support of common ARIA attributes.
- ng-bind Sets the text of a DOM element to the value of an expression. For example, displays the value of ‘name’ inside the span element. Any change to the variable ‘name’ in the application's scope reflect instantly in the DOM.
- ng-class Conditionally apply a class, depending on the value of a boolean expression.
- ng-controller Specifies a JavaScript controller class that evaluates HTML expressions.
- ng-if Basic if statement directive that instantiates the following element if the conditions are true. When the condition is false, the element is removed from the DOM. When true, a clone of the compiled element is re-inserted.
- ng-init Called once when the element is initialized.
- ng-model Similar to ng-bind, but establishes a two-way data binding between the view and the scope.
- ng-model-options Provides tuning for how model updates are done.
- ng-repeat Instantiate an element once per item from a collection.
- ng-show & ng-hide Conditionally show or hide an element, depending on the value of a boolean expression. Show and hide is achieved by setting the CSS display style.
- ng-switch Conditionally instantiate one template from a set of choices, depending on the value of a selection expression.
- ng-view The base directive responsible for handling routes[12] that resolve JSON before rendering templates driven by specified controllers.