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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 298 | CSS |
선택과집중
|
2개월 전 | 157 | |
| 297 | CSS |
선택과집중
|
3개월 전 | 360 | |
| 296 | CSS |
선택과집중
|
3개월 전 | 311 | |
| 295 | CSS |
선택과집중
|
3개월 전 | 290 | |
| 294 | CSS |
선택과집중
|
4개월 전 | 414 | |
| 293 | CSS |
선택과집중
|
4개월 전 | 364 | |
| 292 | CSS |
선택과집중
|
4개월 전 | 283 | |
| 291 | CSS |
선택과집중
|
4개월 전 | 291 | |
| 290 | CSS |
선택과집중
|
4개월 전 | 336 | |
| 289 | CSS |
선택과집중
|
4개월 전 | 309 | |
| 288 | CSS |
선택과집중
|
5개월 전 | 393 | |
| 287 | CSS |
선택과집중
|
5개월 전 | 344 | |
| 286 | CSS |
선택과집중
|
5개월 전 | 343 | |
| 285 | CSS |
선택과집중
|
5개월 전 | 364 | |
| 284 | CSS |
선택과집중
|
5개월 전 | 249 | |
| 283 | CSS |
|
2년 전 | 1522 | |
| 282 | CSS | 2년 전 | 2499 | ||
| 281 | CSS | 4년 전 | 4031 | ||
| 280 | CSS | 4년 전 | 4554 | ||
| 279 | 반응형웹 | 5년 전 | 2983 | ||
| 278 | 반응형웹 | 5년 전 | 2833 | ||
| 277 | 부트스트랩 | 7년 전 | 5030 | ||
| 276 | 부트스트랩 | 7년 전 | 6584 | ||
| 275 | 부트스트랩 | 7년 전 | 4667 | ||
| 274 | 부트스트랩 | 7년 전 | 6698 | ||
| 273 | 부트스트랩 | 7년 전 | 3365 | ||
| 272 | 부트스트랩 | 7년 전 | 3201 | ||
| 271 | 부트스트랩 | 7년 전 | 3704 | ||
| 270 | 부트스트랩 | 7년 전 | 3226 | ||
| 269 | 부트스트랩 | 7년 전 | 3100 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기