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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 178 | AngularJS | 8년 전 | 1424 | ||
| 177 | AngularJS | 8년 전 | 1198 | ||
| 176 | AngularJS | 8년 전 | 1273 | ||
| 175 | AngularJS | 8년 전 | 1363 | ||
| 174 | AngularJS | 8년 전 | 1137 | ||
| 173 | AngularJS | 8년 전 | 1878 | ||
| 172 | AngularJS | 8년 전 | 1434 | ||
| 171 | AngularJS | 8년 전 | 1127 | ||
| 170 | AngularJS | 8년 전 | 1391 | ||
| 169 | AngularJS | 8년 전 | 1187 | ||
| 168 | AngularJS | 8년 전 | 1000 | ||
| 167 | AngularJS | 8년 전 | 1963 | ||
| 166 | AngularJS | 8년 전 | 1036 | ||
| 165 | AngularJS | 8년 전 | 1101 | ||
| 164 | AngularJS | 8년 전 | 1304 | ||
| 163 | AngularJS | 8년 전 | 1150 | ||
| 162 | AngularJS | 8년 전 | 1363 | ||
| 161 | AngularJS | 8년 전 | 1368 | ||
| 160 | AngularJS | 8년 전 | 1122 | ||
| 159 | AngularJS | 8년 전 | 1090 | ||
| 158 | AngularJS | 8년 전 | 1501 | ||
| 157 | AngularJS | 8년 전 | 1473 | ||
| 156 | AngularJS | 8년 전 | 1321 | ||
| 155 | AngularJS | 8년 전 | 1210 | ||
| 154 | AngularJS | 8년 전 | 1609 | ||
| 153 | AngularJS | 8년 전 | 1078 | ||
| 152 | AngularJS | 8년 전 | 1492 | ||
| 151 | AngularJS | 8년 전 | 1414 | ||
| 150 | AngularJS | 8년 전 | 1108 | ||
| 149 | AngularJS | 8년 전 | 1638 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기