У меня есть следующий HTML
<span class="items-count">{{items | countmessage}}</span>
И следующий фильтр, чтобы отобразить правильное количество сообщений
app.filters
.filter('countmessage', function () {
return function (input) {
var result = input.length + ' item';
if (input.length != 1) result += 's';
return message;
}
});
но я хочу использовать разные слова вместо "item (s)", поэтому я изменил фильтр
app.filters
.filter('countmessage', function () {
return function (input, itemType) {
var result = input.length + ' ' + itemType;
if (input.length != 1) result += 's';
return message;
}
});
он работает, когда я использую такую строку
<span class="items-count">{{items | countmessage:'car'}}</span>
но не работает с переменной из области $scope, возможно ли использовать переменную $scope
<span class="items-count">{{items | countmessage:itemtype}}</span>
Спасибо