Created
February 2, 2014 16:05
-
-
Save kazuph/8770532 to your computer and use it in GitHub Desktop.
AngularJSでng-repeatした要素ごとに独立した処理を実行させる ref: http://qiita.com/kazuph/items/c098cd75b1208fcc2a85
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 ng-controller="myController"> | |
<div ng-repeat="f in forms"> | |
{{f}} | |
<input ng-model="data[f]" ng-keyup="doChange(f)"> | |
{{dataTimes[f]}} | |
</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
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