Skip to content

Instantly share code, notes, and snippets.

@cmstead
Created January 27, 2015 00:00
Show Gist options
  • Save cmstead/486d1c860cbf09b5f7b3 to your computer and use it in GitHub Desktop.
Save cmstead/486d1c860cbf09b5f7b3 to your computer and use it in GitHub Desktop.
WbOWLq
<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>
(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