AngularJS Controllers - Controller Methods
AngularJS Controllers - Controller Methods
Controller Methods(컨트롤러 메소드)
위 예제는 lastName과 firstName의 두 가지 속성을 가진 컨트롤러 객체를 보여줍니다.
컨트롤러는 메소드 (변수를 함수로)를 가질 수도 있습니다 :
<div ng-app="myApp" ng-controller="personCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
});
</script>
전체소스
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="personCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
});
</script>
</body>
</html>
Controller Methods(컨트롤러 메소드)
위 예제는 lastName과 firstName의 두 가지 속성을 가진 컨트롤러 객체를 보여줍니다.
컨트롤러는 메소드 (변수를 함수로)를 가질 수도 있습니다 :
<div ng-app="myApp" ng-controller="personCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
});
</script>
전체소스
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="personCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
});
</script>
</body>
</html>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 148 | AngularJS | 8년 전 | 1663 | ||
| 147 | AngularJS | 8년 전 | 1080 | ||
| 146 | AngularJS | 8년 전 | 1266 | ||
| 145 | AngularJS | 8년 전 | 1373 | ||
| 144 | AngularJS | 8년 전 | 1163 | ||
| 143 | AngularJS | 8년 전 | 1207 | ||
| 142 | AngularJS | 8년 전 | 1176 | ||
| 141 | AngularJS | 8년 전 | 1337 | ||
| 140 | AngularJS | 8년 전 | 1203 | ||
| 139 | AngularJS | 8년 전 | 1449 | ||
| 138 | AngularJS | 8년 전 | 1156 | ||
| 137 | AngularJS | 8년 전 | 1066 | ||
| 136 | AngularJS | 8년 전 | 1166 | ||
| 135 | AngularJS | 8년 전 | 1684 | ||
| 134 | AngularJS | 8년 전 | 1391 | ||
| 133 | AngularJS | 8년 전 | 1485 | ||
| 132 | AngularJS | 8년 전 | 1105 | ||
| 131 | AngularJS | 8년 전 | 1376 | ||
| 130 | AngularJS | 8년 전 | 1466 | ||
| 129 | AngularJS | 8년 전 | 1450 | ||
| 128 | AngularJS | 8년 전 | 2070 | ||
| 127 | AngularJS | 8년 전 | 1494 | ||
| 126 | jQuery Mobile | 8년 전 | 2268 | ||
| 125 | jQuery Mobile | 8년 전 | 2027 | ||
| 124 | jQuery Mobile | 8년 전 | 1891 | ||
| 123 | jQuery Mobile | 8년 전 | 1825 | ||
| 122 | jQuery Mobile | 8년 전 | 1863 | ||
| 121 | jQuery Mobile | 8년 전 | 2067 | ||
| 120 | jQuery Mobile | 8년 전 | 1602 | ||
| 119 | jQuery Mobile | 8년 전 | 1681 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기