【发布时间】:2015-11-26 09:19:08
【问题描述】:
我在应用程序的其他地方生成了这段代码
"PHcolour":"rgb(4, 31, 156)","Ctextcolour":"rgb(59, 214, 252)"
我得到了很好的数据(来自模型),使用波浪括号{{CtextColour}}
我想在我的页面上有一个可以更改网站配色方案的按钮。我使用ng-click
现在我遇到的问题是 css 不接受 {{}} 所以我尝试这样做的方法是这样的
<style media="screen">
.custom { background-color: #fff; }
.custom h1 { color: {{Ctextcolour}}; }
.custom h2 { color: {{Ctextcolour}}; }
.custom h3 { color: {{Ctextcolour}}; }
.custom h4 { color: {{Ctextcolour}}; }
.custom h5 { color: {{Ctextcolour}}; }
.custom h6 { color: {{Ctextcolour}}; }
.custom p { color: {{Ctextcolour}}; }
.custom th { background-color: #c3cced; color: {{Ctextcolour}};}
.custom.panel-heading { background-image:-webkit-linear-gradient(top, #c3cced, #c3cced ) !important; color: {{Ctextcolour}} !important;}
</style>
这不起作用(并且还在我的 IDE (Atom) 中将我的 html 代码的其余部分变成了粉红色
我尝试将它切换到去除粉红色的这个,但仍然没有工作!
<ng-style media="screen">
.custom { background-color: #fff; }
.custom h1 { color: {{Ctextcolour}}; }
.custom h2 { color: {{Ctextcolour}}; }
.custom h3 { color: {{Ctextcolour}}; }
.custom h4 { color: {{Ctextcolour}}; }
.custom h5 { color: {{Ctextcolour}}; }
.custom h6 { color: {{Ctextcolour}}; }
.custom p { color: {{Ctextcolour}}; }
.custom th { background-color: #c3cced; color: {{Ctextcolour}};}
.custom.panel-heading { background-image:-webkit-linear-gradient(top, #c3cced, #c3cced ) !important; color: {{Ctextcolour}} !important;}
</ng-style>
按钮的html是这样的:
<button type="button" class="btn btn-info" ng-click="colorScheme = 'custom'" ng-model="eventData.theme">Custom Theme
</button>
inspect 元素显示按钮没有添加任何内容,也没有任何 javascript 错误。
谢谢
【问题讨论】: