crmApp.directive('udArrow', function () {
return {
Restrict: 'A',
link: function (scope, element, attrs) {
var upArrow = '↑';
var downArrow = '↓';
scope.resultTemplate = '';
if (attrs.val1 > attrs.val2) {
scope.resultTemplate =(upArrow);
}
else {
scope.resultTemplate = (downArrow);
}
},
template: '<span>{{resultTemplate}}</span>'
}
});
结果是(我故意分开分号而不是构成箭头) &amp;#x2191;
我也非常欣赏更好的解决方案。 :)
答案 0 :(得分:1)
crmApp.directive('udArrow', function () {
return {
Restrict: 'A',
link: function (scope, element, attrs) {
var upArrow = '↑';
var downArrow = '↓';
scope.resultTemplate = '';
if (attrs.val1 > attrs.val2) {
scope.resultTemplate =(upArrow);
}
else {
scope.resultTemplate = (downArrow);
}
},
template: '<span><div ng-bind-html="resultTemplate"></div></span>'
}