Skip to content

Instantly share code, notes, and snippets.

@kazuph
Created February 2, 2014 16:05
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 kazuph/8770532 to your computer and use it in GitHub Desktop.
Save kazuph/8770532 to your computer and use it in GitHub Desktop.
AngularJSでng-repeatした要素ごとに独立した処理を実行させる ref: http://qiita.com/kazuph/items/c098cd75b1208fcc2a85
<div ng-controller="myController">
<div ng-repeat="f in forms">
{{f}}
<input ng-model="data[f]" ng-keyup="doChange(f)">
{{dataTimes[f]}}
</div>
</div>
var myApp = angular.module('myApp', []);
myApp.controller('myController', ['$scope', function($scope) {
$scope.forms = {
0: "hoge",
1: "fuga",
2: "piyo"
};
$scope.data = {};
$scope.dataTimes = {};
$scope.doChange = function(f){
console.log($scope.data);
$scope.dataTimes[f] = $scope.data[f] * 3;
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment