這是我的HTML代碼中,我希望過濾器來執行:如何使用過濾器插入換行符?
<div class="col-xs-4 col-sm-15 previewBtnCont" ng-repeat="category in NavigationModel.pageArray" >
<button class="btn btn-lrg previewContentBtns" >
<div ng-bind="category.categoryDescription|filterPreviewBtnLabels"></div>
</button>
</div>
的邏輯是,如果按鈕標籤超過10個字符,然後從11日起,字符它轉到下一行。我寫的過濾器正在工作,但換行符「
」顯示爲一個字符串,而不是換行符。該過濾器的功能是:
common.filter('filterPreviewBtnLabels', function() {
var testString = "Hello";
return function(value){
if (!angular.isString(value)) {
return value;
}
return value + "<br>" + testString;
};
});
如果按鈕標籤是雞它應該顯示「雞」線斷開,然後「你好」,但它只是顯示「雞
你好」。
任何援助是最受歡迎的。
注:是寫一個正確的方法在HTML中換行 –
轉發其
– Yash
嘿,這是CSS的東西。簡單的最大寬度和文字包裝應該做的訣竅... –