Plunker:http ://plnkr.co/edit/XBJjr6uR1rMAg3Ng7DiJ?p=preview
我希望这两个看起来一样:
<span dt-attrib="{{person.name}}">This won't be here</span><br/>
<span class="dt-class: {{person.name}};">This won't be here.</span> - this does not process
但这就是我得到的:
This text was set by the dtAttrib directive, value="Burt Finklestein"
This text was set by the dtClass directive, value="{{person.name}}"
代码:
app.directive("dtAttrib", function() {
return {
restrict: "A",
link: function(scope, element, attrs) {
element.text('This text was set by the dtAttrib directive' + DisplayValueString(attrs.dtAttrib));
}
}
}
});
app.directive("dtClass", function() {
return {
restrict: "C",
link: function(scope, element, attrs) {
element.text('This text was set by the dtClass directive' + DisplayValueString(attrs.dtClass));
}
};
});