下面有这段代码,我想用 CSS 对其进行样式设置,但我的样式表仅影响标题,而不影响单击时框中的文本。如何使 CSS 样式表对文本有效?或者我如何定位该文本来设置其样式?
function MyCtrl($scope) {
$scope.environment_service_packages =
[
{name: 'Styles displayed here', info: {text: 'Styles not displayed here', show: true}},
{name: 'obj2', info: {text: 'some extra info for obj2', show: false}},
{name: 'obj3', info: {text: 'some extra info for obj3', show: false}},
{name: 'obj4', info: {text: 'some extra info for obj4', show: false}},
];
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app>
<table ng-controller="MyCtrl" class="table table-hover table-striped">
<tr class="info">
<td>...</td>
</tr>
<tbody ng-repeat="x in environment_service_packages">
<tr ng-click="x.info.show = !x.info.show">
<td> {{ x.name }}
</tr>
<tr ng-show="x.info.show">
<td>
<pre>{{ x.info.text }}</pre>
</td>
</tr>
</tbody>
</table>
</body>
最佳答案
我意识到我在一个页面中使用了两个相互冲突的样式表,因此删除一个样式表解决了问题。
关于javascript - CSS 样式不显示在 angularjs 文本字段中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38219667/