我正在動態創建存儲在我的服務器上的字體列表。我想通過字體列表ng-repeat
並將每種字體應用到新元素。ng-repeat @ font-face樣式不起作用
所以這是我在做什麼:
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-4" ng-repeat="font in ctrl.fontList">
<style>
@font-face {font-family:"{{font.family}}"; src: url({{font.url}});}
</style>
<svg height="100%" width="100%" position>
<rect x="0" y="0" width="100%" height="100%" fill="#288feb"></rect>
<g class="groupLayer">
<text fill="#ffffff" x="0" y="0" font-size="48" font-family="{{font.family}}"
>{{ctrl.text}}</text>
</g>
</svg>
</div>
</div>
這可能是一個很大的禁忌在HTML,但我有我的style
內我div
,我是不是要得到這個工作的任何可能的方式。
無論如何,這不適合我。
{{font.family}}
輸出OstrichSans-Black
和{{font.url}}
在本地託管在我的localhost
和URL是有效的。
任何想法爲什麼這不起作用?我該怎麼辦?
不要忘記字體系列的引號。或者,更好的是,使用'ng-style'。 – cdhowie
沒有,只是默認爲'body'字體...即使有一個'!important'在其上 – Katie
@Katie而不是使用模板嘗試我的代碼片段與您正在加載的字體的名稱。 font-family:'FontName'; –