앵큘러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 형식으로 사용합니다.
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 58 | jQuery Mobile | 8년 전 | 2988 | ||
| 57 | jQuery Mobile | 8년 전 | 2031 | ||
| 56 | jQuery Mobile | 8년 전 | 1367 | ||
| 55 | jQuery Mobile | 8년 전 | 1557 | ||
| 54 | jQuery Mobile | 8년 전 | 2237 | ||
| 53 | jQuery Mobile | 8년 전 | 1537 | ||
| 52 | jQuery Mobile | 8년 전 | 1559 | ||
| 51 | jQuery Mobile | 8년 전 | 1426 | ||
| 50 | jQuery Mobile | 8년 전 | 1315 | ||
| 49 | jQuery Mobile | 8년 전 | 1818 | ||
| 48 | jQuery Mobile | 8년 전 | 1461 | ||
| 47 | jQuery Mobile | 8년 전 | 2020 | ||
| 46 | jQuery Mobile | 8년 전 | 1980 | ||
| 45 | jQuery Mobile | 8년 전 | 1514 | ||
| 44 | jQuery Mobile | 8년 전 | 1676 | ||
| 43 | jQuery Mobile | 8년 전 | 1789 | ||
| 42 | jQuery Mobile | 8년 전 | 1668 | ||
| 41 | jQuery Mobile | 8년 전 | 1835 | ||
| 40 | jQuery Mobile | 8년 전 | 1478 | ||
| 39 | jQuery Mobile | 8년 전 | 1633 | ||
| 38 | jQuery Mobile | 8년 전 | 2181 | ||
| 37 | jQuery Mobile | 8년 전 | 2683 | ||
| 36 | jQuery Mobile | 8년 전 | 2131 | ||
| 35 | jQuery Mobile | 8년 전 | 1522 | ||
| 34 | jQuery Mobile | 8년 전 | 2425 | ||
| 33 | AngularJS | 8년 전 | 2874 | ||
| 32 | AngularJS | 8년 전 | 2436 | ||
| 31 | AngularJS | 8년 전 | 1767 | ||
| 30 | AngularJS | 8년 전 | 2841 | ||
| 29 | AngularJS | 8년 전 | 2401 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기