I am learning AngularJS. I have an app with a controller that looks like the following:
function myController($scope) {
$scope.isOn = false;
$scope.flip = function() {
$scope.isOn = !$scope.isOn;
}
}
My view has the following code:
<div ng-controller="myController">
<button ng-click="flip()">{{isOn}}</button>
</div>
I want isOn to be a true/false value in my controller. However, in my view I want to show "On" if the flag is true. If the flag is false, I want to show "Off". How do I do that? I thought I could possibly use a filter. However, I didn't have any luck with that approach.