A Pen by Chris Stead on CodePen.
Created
January 27, 2015 00:00
-
-
Save cmstead/486d1c860cbf09b5f7b3 to your computer and use it in GitHub Desktop.
WbOWLq
This file contains 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 id="myApp"> | |
<div ng-controller="testController"> | |
<div ng-repeat="record in recordSet"> | |
<div ng-init="myvar = myCrappyMapper(record)"></div> | |
{{record + ' ' + myvar}} | |
</div> | |
<input ng-model="multiplier" /> | |
</div> | |
</div> |
This file contains 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
(function(){ | |
'use strict'; | |
var moduleName = 'myTestApp'; | |
angular.module(moduleName, []); | |
function Controller($scope){ | |
this.$scope = $scope; | |
$scope.recordSet = [ | |
'1', | |
'2', | |
'3', | |
'4', | |
'5', | |
'6' | |
]; | |
$scope.multiplier = '3'; | |
$scope.myCrappyMapper = angular.bind(this, this.myCrappyMapper); | |
$scope.$watch('multiplier', function(value){ | |
console.log(value); | |
}); | |
} | |
Controller.prototype = { | |
myCrappyMapper: function(value){ | |
return value * this.$scope.multiplier; | |
} | |
}; | |
angular.module(moduleName) | |
.controller('testController', ['$scope', Controller]); | |
angular.element('#myApp').ready(function(){ | |
angular.bootstrap(angular.element('#myApp'), ['myTestApp']); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment