Skip to content

Instantly share code, notes, and snippets.

Last active Dec 14, 2015
What would you like to do?
Angular images. Choose image set using data from radio button selection.
<!-- initializing Angular -->
<html ng-app>
<!-- setting default value -->
<script language="javascript">
function Ctrl($scope) {
$scope.graph = 'noise_margin';
<script src=""></script>
<!-- all code evolves Angular should be wrapped inside some container with ng-controller -->
<body ng-controller="Ctrl">
<!-- selecting value, binding data to 'graph' model -->
<form name="graphForm">
<input type="radio" ng-model="graph" value="noise_margin"> noise_margin
<input type="radio" ng-model="graph" value="speed"> speed
<input type="radio" ng-model="graph" value="attenuation"> attenuation
<!-- using selected value to display image via 'ng-src' with 'graph' model -->
<img ng-src="{{graph}}/graph_day.png"><br><br>
<img ng-src="{{graph}}/graph_week.png"><br><br>
<img ng-src="{{graph}}/graph_month.png"><br><br>
<img ng-src="{{graph}}/graph_year.png">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment