コンパイルするAngularディレクティブがあります
<greeting /><print-greeting />と_<print-greeting />にHello World!
greetingタグを HTML に挿入し、コンパイルしてprint-greeting最終的に表示するにはどうすればよいHello World!ですか? に変えて現在停止中print-greetingです。
これが私のコードです: Plunker。
上記のプランカーからコピーされたディレクティブ:
greeting指令
// Transforms <greeting /> into <print-greeting />
app.directive("greeting", function ($compile) {
return {
restrict: 'E',
priority: 2,
compile: function ($templateElement, $templateAttributes) {
var template = '<print-greeting />';
$templateElement.replaceWith(template);
return function LinkingFunction($scope, $element, $attrs) { };
}
};
});
print-greeting指令
// Transforms <print-greeting /> into "Hello World!"
app.directive("printGreeting", function ($compile) {
return {
restrict: 'E',
priority: 1,
compile: function ($templateElement, $templateAttributes) {
var template = 'Hello World!';
$templateElement.replaceWith(template);
return function LinkingFunction($scope, $element, $attrs) { };
}
};
});