이 코드에서 뭔가 잘못하고있는 것 같습니다. 확실하지 않지만 정말 잘못되었습니다.
버튼을 클릭하면 배경색과 텍스트가 글꼴이 변경되도록하고 싶습니다.
<style>
.red { background-color: red; }
.red p { font-style: normal; }
.blue { background-color: blue; }
.blue p { font-style: italic; }
.green { background-color: green; }
.green p { font-style: oblique;}
</style>
<div ng-class={{colorScheme}}>
<button ng-click="colorScheme = 'red'">ColorScheme Red</button>
<button ng-click="colorScheme = 'blue'">ColorScheme Blue</button>
<button ng-click="colorScheme = 'green'">ColorScheme Green</button>
<p>Awesome content</p>
</div>
ng-class
like에 범위 변수를 전달하십시오.
var app = angular.module('my-app', [], function() {})
app.controller('AppController', function($scope) {})
.red {
background-color: red;
}
.red p {
font-style: normal;
}
.blue {
background-color: blue;
}
.blue p {
font-style: italic;
}
.green {
background-color: green;
}
.green p {
font-style: oblique;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="my-app" ng-controller="AppController">
<div ng-class="colorScheme">
<button ng-click="colorScheme = 'red'">ColorScheme Red</button>
<button ng-click="colorScheme = 'blue'">ColorScheme Blue</button>
<button ng-click="colorScheme = 'green'">ColorScheme Green</button>
<p>Awesome content</p>
</div>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다