AngularJS表單基本操作
本文實(shí)例為大家分享了AngularJS表單簡(jiǎn)單操作代碼,供大家參考,具體內(nèi)容如下
HTML正文:
<div ng-app="myApp" ng-controller="myCtrl">
<!-- novalidate:當(dāng)提交表單時(shí)不對(duì)表單數(shù)據(jù)(輸入)進(jìn)行驗(yàn)證 -->
<form novalidate>
First Name:<input type="text" ng-model="user.firstName"><br>
Last Name:<input type="text" ng-model="user.lastName">
<br><br>
<button ng-click="reset()">RESET</button>
</form>
<p>form = {{user }}</p>
<p><font color="red">initInfo = {{initInfo}}</font></p>
</div>
Javascript操作代碼:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.initInfo = {firstName:"squirrel", lastName:"Python"};
$scope.reset = function() {
$scope.user = angular.copy($scope.initInfo); // user對(duì)象等于master對(duì)象:深復(fù)制
};
//JS掃描腳本時(shí)會(huì)自動(dòng)調(diào)用reset方法進(jìn)行輸入框信息的初始化
$scope.reset();
});
效果:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- AngularJS模仿Form表單提交的實(shí)現(xiàn)代碼
- 詳細(xì)分析使用AngularJS編程中提交表單的方式
- AngularJS表單編輯提交功能實(shí)例
- angularJS提交表單(form)
- AngularJs表單校驗(yàn)功能實(shí)例代碼
- AngularJS實(shí)現(xiàn)表單驗(yàn)證功能
- AngularJS中實(shí)現(xiàn)用戶訪問的身份認(rèn)證和表單驗(yàn)證功能
- AngularJS 使用 UI Router 實(shí)現(xiàn)表單向?qū)?/a>
- AngularJS使用ngMessages進(jìn)行表單驗(yàn)證
- AngularJS實(shí)現(xiàn)表單驗(yàn)證
- AngularJS表單提交實(shí)例詳解
相關(guān)文章
AngularJS基于ngInfiniteScroll實(shí)現(xiàn)下拉滾動(dòng)加載的方法
這篇文章主要介紹了AngularJS基于ngInfiniteScroll實(shí)現(xiàn)下拉滾動(dòng)加載的方法,結(jié)合實(shí)例形式分析AngularJS下拉滾動(dòng)插件ngInfiniteScroll的下載、功能、屬性及相關(guān)使用方法,需要的朋友可以參考下2016-12-12
Angular.js實(shí)現(xiàn)多個(gè)checkbox只能選擇一個(gè)的方法示例
Angular2使用Angular CLI快速搭建工程(一)
AngularJS實(shí)現(xiàn)tab選項(xiàng)卡的方法詳解
Angular?Tree?Shaking優(yōu)化機(jī)制原理詳解
詳解Angular-cli生成組件修改css成less或sass的實(shí)例
詳解使用angular框架離線你的應(yīng)用(pwa指南)

