앵큘러js 간단한 예제
앵큘러js 간단한 예제
<div ng-app="myApp" ng-controller="formCtrl">
<form novalidate>
First Name:<br>
<input type="text" ng-model="user.firstName"><br>
Last Name:<br>
<input type="text" ng-model="user.lastName">
<br><br>
<button ng-click="reset()">RESET</button>
</form>
<p>form = {{user}}</p>
<p>master = {{master}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('formCtrl', function($scope) {
$scope.master = {firstName: "John", lastName: "Doe"};
$scope.reset = function() {
$scope.user = angular.copy($scope.master);
};
$scope.reset();
});
</script>
예제 설명
ng-app 프로그램 지시문은 AngularJS와 응용 프로그램을 정의합니다.
ng-controller 지시어는 응용 프로그램 컨트롤러를 정의합니다.
ng-model 지시자는 두 입력 요소 결합 사용자 모델의 개체.
formCtrl 제어기는 초기 값으로 설정 마스터 개체 정의 및 리셋 () 방법.
reset() 메소드 세트 사용자 받는 동일한 개체 마스터 개체.
ng-click 지시문은 호출 리셋 () 버튼을 클릭 할 경우에만 방법.
novalidate 속성은이 애플리케이션에서 필요하지 않지만 일반적으로 표준 HTML5 유효성 검사를 재정의하기 위해 AngularJS 형식으로 사용합니다.
<div ng-app="myApp" ng-controller="formCtrl">
<form novalidate>
First Name:<br>
<input type="text" ng-model="user.firstName"><br>
Last Name:<br>
<input type="text" ng-model="user.lastName">
<br><br>
<button ng-click="reset()">RESET</button>
</form>
<p>form = {{user}}</p>
<p>master = {{master}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('formCtrl', function($scope) {
$scope.master = {firstName: "John", lastName: "Doe"};
$scope.reset = function() {
$scope.user = angular.copy($scope.master);
};
$scope.reset();
});
</script>
예제 설명
ng-app 프로그램 지시문은 AngularJS와 응용 프로그램을 정의합니다.
ng-controller 지시어는 응용 프로그램 컨트롤러를 정의합니다.
ng-model 지시자는 두 입력 요소 결합 사용자 모델의 개체.
formCtrl 제어기는 초기 값으로 설정 마스터 개체 정의 및 리셋 () 방법.
reset() 메소드 세트 사용자 받는 동일한 개체 마스터 개체.
ng-click 지시문은 호출 리셋 () 버튼을 클릭 할 경우에만 방법.
novalidate 속성은이 애플리케이션에서 필요하지 않지만 일반적으로 표준 HTML5 유효성 검사를 재정의하기 위해 AngularJS 형식으로 사용합니다.
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 118 | jQuery Mobile | 8년 전 | 1347 | ||
| 117 | jQuery Mobile | 8년 전 | 1594 | ||
| 116 | jQuery Mobile | 8년 전 | 1825 | ||
| 115 | jQuery Mobile | 8년 전 | 1780 | ||
| 114 | jQuery Mobile | 8년 전 | 1969 | ||
| 113 | jQuery Mobile | 8년 전 | 1878 | ||
| 112 | jQuery Mobile | 8년 전 | 2486 | ||
| 111 | jQuery Mobile | 8년 전 | 1792 | ||
| 110 | jQuery Mobile | 8년 전 | 1581 | ||
| 109 | jQuery Mobile | 8년 전 | 1742 | ||
| 108 | jQuery Mobile | 8년 전 | 1968 | ||
| 107 | jQuery Mobile | 8년 전 | 1772 | ||
| 106 | jQuery Mobile | 8년 전 | 1450 | ||
| 105 | jQuery Mobile | 8년 전 | 1747 | ||
| 104 | jQuery Mobile | 8년 전 | 2424 | ||
| 103 | jQuery Mobile | 8년 전 | 1562 | ||
| 102 | jQuery Mobile | 8년 전 | 1504 | ||
| 101 | jQuery Mobile | 8년 전 | 1696 | ||
| 100 | jQuery Mobile | 8년 전 | 1922 | ||
| 99 | jQuery Mobile | 8년 전 | 1375 | ||
| 98 | jQuery Mobile | 8년 전 | 1397 | ||
| 97 | jQuery Mobile | 8년 전 | 1658 | ||
| 96 | jQuery Mobile | 8년 전 | 1309 | ||
| 95 | jQuery Mobile | 8년 전 | 1127 | ||
| 94 | jQuery Mobile | 8년 전 | 1528 | ||
| 93 | jQuery Mobile | 8년 전 | 1147 | ||
| 92 | jQuery Mobile | 8년 전 | 1569 | ||
| 91 | jQuery Mobile | 8년 전 | 1516 | ||
| 90 | jQuery Mobile | 8년 전 | 1681 | ||
| 89 | jQuery Mobile | 8년 전 | 1668 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기