angularjs的文档:
myModule.directive('directiveName', function factory(injectables) {
var directiveDefinitionObject = {
priority: 0,
template: '<div></div>',
templateUrl: 'directive.html',
replace: false,
transclude: false,
restrict: 'A',
scope: false,
compile: function compile(tElement, tAttrs, transclude) {
return {
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
post: function postLink(scope, iElement, iAttrs, controller) {
// ????
// is it possible to set the content of iElement?
}
}
}
};
return directiveDefinitionObject;
});
在postLink
函数里面compile
,是否可以设置一些文本iElement
?
我试过了:
iElement.html("some");
iElement.textContent = "some";
jQuery(iElement).html("some");
但似乎它们都没有奏效。