<html class="ng-app" id="ng-app">
<head>
<title>angularjs兼容性解决</title>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="json3.min.js"></script>
</head>
<body>
<script>
function Ctrl($scope) {
$scope.list = [];
$scope.text = 'hello';
$scope.submit = function() {
if ($scope.text) {
$scope.list.push(this.text);
$scope.text = '';
}
};
}
</script>
<form ng-submit="submit()" ng-controller="Ctrl">
Enter text and hit enter:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />
<pre>list={{list}}</pre>
</form>
</body>
<head>
<title>angularjs兼容性解决</title>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="json3.min.js"></script>
</head>
<body>
<script>
function Ctrl($scope) {
$scope.list = [];
$scope.text = 'hello';
$scope.submit = function() {
if ($scope.text) {
$scope.list.push(this.text);
$scope.text = '';
}
};
}
</script>
<form ng-submit="submit()" ng-controller="Ctrl">
Enter text and hit enter:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />
<pre>list={{list}}</pre>
</form>
</body>
</html>
源码地址:http://download.youkuaiyun.com/detail/cptcpt123/7268281
本文通过一个简单的AngularJS示例介绍了如何使用AngularJS进行表单数据的收集与提交。示例中包括了一个用于输入文本并提交的表单,每当用户点击提交按钮或按下回车键时,输入的文本会被添加到列表中。此示例还展示了如何使用AngularJS的指令和控制器。
1369





