Below you can see an example of my Code - The app is running fine, so when I click on 'Toggle', the app is switching between the two Variables.
<body>
<div ng-init="value = 'off'" ng-app='app' ng-controller="myctrl">
<h1 ng-click="value = { 'on': 'off', 'off':'on'}[value]; event.PreventDefault;">Toggle</h1>
<h3 ng-show="value == 'on'" >{{var1}}</h1>
<h3 ng-show="value == 'off'" >{{var2}}</h1>
</div>
<script>
(function () {
'use strict';
angular.module('app', [])
.controller('myctrl', myctrl);
function myctrl($scope){
$scope.var1 = "Its on";
$scope.var2 = "Its off";
}
})();
</script>
Following Question: How can I implement this, or what is best practice that I just need one "h3" tag to switch between the variables ? Because I have a lot of other information in my html tag and I always repeating me for just toggle of two Variables...