【发布时间】:2014-04-14 21:05:00
【问题描述】:
我需要将多 css 规则应用于角度表单模板中的 html 标记。
<div class="form-control" id="data.objectStyle"
ng-model="data.type"
ng-style="getStyle(data.objectStyle)">
{{data.objectStyle.title}}
</div>
控制器中的getStyle函数:
$scope.getStyle = function (taskType) {
return {
background-color:taskType.backColor,
color: taskType.color,
font-size:taskType.fontSize,
font-family:taskType.font
}
)};
taskType 对象:
{
backColor:'#006',
color:'#56DA',
fontSize:12,
font:'New Times Roman'
}
getStyle 函数不返回样式!怎么办?
【问题讨论】:
-
您没有包含足够的代码。函数返回什么?
taskType.backColor等的值是多少? -
@Ed Hinchliffe taskType = {backColor:'#006',color:'#56DA',fontSize:12,font:'New Times Roman'}。
-
那应该可以了。控制台出错?