Skip to content

Instantly share code, notes, and snippets.

@seralf
Created July 28, 2016 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seralf/b68a668fd89b9ab66a64af2ff4cc8c95 to your computer and use it in GitHub Desktop.
Save seralf/b68a668fd89b9ab66a64af2ff4cc8c95 to your computer and use it in GitHub Desktop.
code snippet for prototyping a simple angular debug component
<!-- initialize ng-app ... -->
<!-- debug -->
<hr/>
<section id="debug" ng-controller="debugCtrl">
<style>
#debug {
padding: 1em;
background: #DDD;
}
#debug ul li{
display: inline;
padding-right: 1em;
}
#debug ul li{
background: #AAA;
padding: 0.2em;
}
#debug input, #debug button {
border: 1px solid #AAA;
background: #FFA;
}
</style>
<script>
app.controller("debugCtrl", function($scope) {
$scope.selection = {};
var colors = "white yellow red green blue".split(" ");
$scope.selection.colors = colors;
$scope.add_color = function () {
$scope.selection.colors.push($scope.color);
}
});
</script>
<ul>
<li ng-repeat="x in selection.colors track by $index">
<span style="color:{{x}};">{{x}}</span>
</li>
</ul>
<input ng-model="color" />
<button ng-click="add_color()">Add</button>
<pre>{{selection | json}}</pre>
</section>
<hr/>
<!-- debug -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment