Created
June 14, 2017 17:41
-
-
Save Jonathancollinet/0f68fe30c1ec826cde707a45c3a8bf16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app="myApp"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<style> | |
.green { | |
background: green; | |
} | |
.purple { | |
background: purple; | |
} | |
</style> | |
</head> | |
<body> | |
<div ng-controller="mainCtrl as main"> | |
<button ng-click="main.changeStyle()">Clickme</button> | |
<p ng-class="main.toggleColor ? 'green' : 'purple'">toto!</p> | |
</div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular.js"></script> | |
<script src="/index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("myApp", []) | |
.controller("mainCtrl", function() { | |
this.toto = 5 | |
this.toggleColor = 0 | |
this.changeStyle = () => { | |
this.toggleColor = !this.toggleColor | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment