【问题标题】:Show the value of one of the object property in different lines and font size以不同的行和字体大小显示对象属性之一的值
【发布时间】:2018-07-22 04:05:18
【问题描述】:

我有一个带有值的 JavaScript 对象。在网页上显示时,我想以不同字体大小的多行显示值。

演示链接:https://plnkr.co/edit/QQsvz4UJPrRHD84t4CkC?p=preview

对象:

 $scope.list = [
            {id:'January',description: 'Jan summary \n new line text', start:new Date(2017, 11, 3), end:new Date(2017, 11, 3)},
            {id:'January',description:'ails \n new line text with small font',start:new Date(2018, 1, 3), end:new Date(2018, 2, 3)},
            {id:'February',description: 'feb details1 text here',start: new Date(2017, 11, 17), end:new Date(2017, 11, 17)},
            {id:'February',description: 'February details2 text here2', start: new Date(2017, 11, 17), end:new Date(2017, 11, 17)},
            {id:'may',description: 'may text first data here', start: new Date(2017, 11, 17), end:new Date(2017, 11, 17)},
          ];

如何以多行和不同的字体大小显示描述字段中显示的值。我尝试如下所示附加\n,但现在在新行中显示\n 之后的文本. 任何输入...

description:'ails \n new line text with small font'

【问题讨论】:

标签: html css angularjs twitter-bootstrap-3


【解决方案1】:

最好的方法是将描述键值对分离到一个包含两个不同字符串的数组中,然后使用 HTML 显示它。喜欢 -

description: ['ails','小字体换行']

<div ng-repeat="l in list">
     <h2>l.description[0]</h2>
     <h3>l.description[1]</h3>
</div>

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2019-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 2019-11-23
    相关资源
    最近更新 更多