132
6
章 ディレクティブ
AngularJS
のドキュメントでは、これらの記法の代わりにキャメルケースが使われています。
例えば、
ng-repeat
についてのドキュメントは
ngRepeat
という項に記述されています。後ほど詳
しく解説しますが、独自のディレクティブを定義する際にはこのキャメルケースが使われます。
ほとんどの読者は使わないと思われますが、構文規則として
HTML
を使う場合は今までの例と
同様に
namespace-directive-name
の記法でもかまいません。
6.2
API
の概要
ディレクティブの定義を疑似コードで表すと、以下のようになります。
var myModule = angular.module(...);
myModule.directive('namespaceDirectiveName', function factory(
注入された依存先
) {
var
ディレクティブの定義
= {
rest
rict:
文字列
,
priority:
数値
,
template:
文字列
,
templateUrl:
文字列
,
replace:
真偽値
,
transclude:
真偽値
,
scope:
真偽値またはオブジェクト
,
controller: function controllerConstructor
($scope, $element, $attrs, $transclude),
require:
文字列
,
link: function postLink(scope, iElement, ...