顯示具有 AngularJS 標籤的文章。 顯示所有文章
顯示具有 AngularJS 標籤的文章。 顯示所有文章

2014年11月24日 星期一

[AngularJS] Directive Matching (屬性名稱辨識)



正規化處理程序

1. 把 element 或者 attribute 開頭的 x- 和 data- 都去掉。
2. 把用「:」、「-」、「_」隔開的名稱合在一起變成 camelCase 的形式。

範例

<div ng-controller="Controller">
  Hello <input ng-model='name'> <hr/>
  <span ng-bind="name"></span> <br/>
  <span ng:bind="name"></span> <br/>
  <span ng_bind="name"></span> <br/>
  <span data-ng-bind="name"></span> <br/>
  <span x-ng-bind="name"></span> <br/>
</div>
上面的每一行同樣都是使用 ngBind 的意思。


2014年9月18日 星期四

[AngularJS] Scope issues when using custom directive (用客製 directive 的 scope 注意事項)



當使用 AngularJS 客製化的 HTML 標籤 (Directive) 時,
要特別注意 Scope,下面敘述五種不同設定下的 Scope 差別。

預備知識

scope 和 transclude 的預設值皆為 false。