JSFiddle - React, Tailwind, and code Playground
Angular header translate test
by Csaba Hellinger
HTML
<div ng-app="app">
<div ng-controller="MyController">
<h2 ng-if="header.sref">
<a ui-sref="header.sref">{{header.title | translate}} ... </a>
</h2>
<h2 ng-if="!header.sref" translate>
{{header.title}}
</h2>
</div>
</div>
JavaScript
angular.module('app', [])
.controller('MyController', function ($scope) {
console.log('hello');
var obj = { title: 'hello' },
srefs = { one: 'refOne', two: 'refTwo', three: 'refThree' },
something = 'four';
$scope.header = { sref: srefs[something], title: obj.title };
})
.filter('translate', function () {
return function (text) {
return text.toUpperCase();
};
})
.directive('translate', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
$timeout(function () {
element.text(element.text().toUpperCase());
});
}
};
});