Created
October 22, 2014 09:18
-
-
Save yuitakano/600aeac7241eb167e909 to your computer and use it in GitHub Desktop.
ng-form // source http://jsbin.com/bizuke
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
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>ng-form</title> | |
</head> | |
<body> | |
<div ng-controller="MyCtrl"> | |
<form name="test_form" ng-submit="submit()"> | |
<ng-form ng-repeat="key in keys" name="keyForm"> | |
姓名:<input type="text" name="input_name" ng-model="key.name" required> | |
年齡:<input type="text" name="input_age" ng-model="key.age" required> | |
<br> | |
<input type="submit" value="新增" ng-click="addKey()"/> | |
</ng-form> | |
<input type="button" value="儲存" ng-click="click()" /> | |
<input type="submit" value="儲存" ng-click="click()" /> | |
</form> | |
<br> | |
{{keys}} | |
</div> | |
<script id="jsbin-javascript"> | |
function MyCtrl($scope){ | |
$scope.keys = []; | |
$scope.keys.push({ name: 'ANNA',age:18}); | |
$scope.addKey = function () { | |
$scope.keys.push({ name: '',age:null}); | |
}; | |
$scope.submit = function () { | |
console.log($scope.keys); | |
}; | |
$scope.click = function(){ | |
console.log($scope.keys+$scope.keys); | |
}; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function MyCtrl($scope){ | |
$scope.keys = []; | |
$scope.keys.push({ name: 'ANNA',age:18}); | |
$scope.addKey = function () { | |
$scope.keys.push({ name: '',age:null}); | |
}; | |
$scope.submit = function () { | |
console.log($scope.keys); | |
}; | |
$scope.click = function(){ | |
console.log($scope.keys+$scope.keys); | |
}; | |
}</script></body> | |
</html> |
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 MyCtrl($scope){ | |
$scope.keys = []; | |
$scope.keys.push({ name: 'ANNA',age:18}); | |
$scope.addKey = function () { | |
$scope.keys.push({ name: '',age:null}); | |
}; | |
$scope.submit = function () { | |
console.log($scope.keys); | |
}; | |
$scope.click = function(){ | |
console.log($scope.keys+$scope.keys); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment