Last active
August 29, 2015 14:20
-
-
Save dguzzo/f7651045f6bf22fe4cc0 to your computer and use it in GitHub Desktop.
great way to cycle values via modulus operator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see One-time Binding section in Angular docs, | |
// https://docs.angularjs.org/guide/expression | |
angular.module('oneTimeBidingExampleApp', []). | |
controller('EventController', ['$scope', function($scope) { | |
var counter = 0; | |
var names = ['Igor', 'Misko', 'Chirayu', 'Lucas']; | |
/* | |
* expose the event object to the scope | |
*/ | |
$scope.clickMe = function(clickEvent) { | |
$scope.name = names[counter % names.length]; | |
counter++; | |
}; | |
}]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="EventController"> | |
<button ng-click="clickMe($event)">Click Me</button> | |
<p id="one-time-binding-example">One time binding: {{::name}}</p> | |
<p id="normal-binding-example">Normal binding: {{name}}</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment