My First Angular App
Simple app that uses angular directives.
by Jim01
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<div id="JimsControllerDiv" ng-Controller="JimController as j">
Is Jim Lynch cool?
<!-- - {{spice}} - {{j.spice}} -->
<br>
<label><input name="contactEmail" ng-model="jimCoolSelection" type="radio" ng-click="onFirstRadioButtonClicked()" id="firstRadioButton" value="yes" checked="checked">Of Course!</label><br>
<label><input name="contactEmail" type="radio" ng-model="jimCoolSelection" id="laInput" value="certainly" ng-click="onFirstRadioButtonClicked()"
checked="false">Certainly!</label><br>
<label>
<input ng-model="noSelected" name="contactEmail" id="noRadioButton" type="radio" ng-click="onNoRadioButtonClicked()" value="no" ng-model="jimCoolSelection"
ng-init="onNoRadioButtonClicked()" checked="false">I don't believe so.</label><br><br>
<div name="errorMessage" class="jimerrormessage" ng-show="errorVisible" ng-init="setErrorInvisible()" id="errorMessage">
<br>
Do you really think that? :'(
<br>
<br>
</div>
</div>
CSS
.jimerrormessage {
font-size: 20px;
color: red;
border: 3px solid red;
border-radius: 60%;
text-align: center;
}
JavaScript
/**
* Created by bobolicious3000 on 1/19/16.
*/
var myApp = angular.module('JimApp', []);
myApp.controller('JimController', ['$scope', function($scope) {
console.log("Initializing JimController.");
$scope.jimCoolSelection = "yes";
$scope.errorVisible = "false";
$scope.onNoRadioButtonClicked = function(noSelected)
{
$scope.errorVisible = true;
console.log("BUTTON CLICKED" + document.getElementById('noRadioButton'));
document.getElementById('noRadioButton').checked = false;
};
$scope.onFirstRadioButtonClicked = function(noSelected)
{
$scope.errorVisible = false;
};
$scope.setErrorInvisible = function()
{
console.log("Setting serror message invisible.");
$scope.errorVisible = false;
}
}]);