AngularJS Services 두번째
AngularJS Services 두번째
$timeout 서비스
이 $timeout서비스는 AngularJS 버전의 window.setTimeout기능입니다.
예
2 초 후 새 메시지 표시 :
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $timeout) {
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 2000);
});
[전체소스]
<!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="myCtrl">
<p>This header will change after two seconds:</p>
<h1>{{myHeader}}</h1>
</div>
<p>The $timeout service runs a function after a specified number of milliseconds.</p>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $timeout) {
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 2000);
});
</script>
</body>
</html>
$interval 서비스
이 $interval서비스는 AngularJS 버전의 window.setInterval기능입니다.
예
매초마다 시간 표시 :
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $interval) {
$scope.theTime = new Date().toLocaleTimeString();
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
});
[전체소스]
<!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="myCtrl">
<p>The time is:</p>
<h1>{{theTime}}</h1>
</div>
<p>The $interval service runs a function every specified millisecond.</p>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $interval) {
$scope.theTime = new Date().toLocaleTimeString();
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
});
</script>
</body>
</html>
$timeout 서비스
이 $timeout서비스는 AngularJS 버전의 window.setTimeout기능입니다.
예
2 초 후 새 메시지 표시 :
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $timeout) {
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 2000);
});
[전체소스]
<!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="myCtrl">
<p>This header will change after two seconds:</p>
<h1>{{myHeader}}</h1>
</div>
<p>The $timeout service runs a function after a specified number of milliseconds.</p>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $timeout) {
$scope.myHeader = "Hello World!";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 2000);
});
</script>
</body>
</html>
$interval 서비스
이 $interval서비스는 AngularJS 버전의 window.setInterval기능입니다.
예
매초마다 시간 표시 :
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $interval) {
$scope.theTime = new Date().toLocaleTimeString();
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
});
[전체소스]
<!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="myCtrl">
<p>The time is:</p>
<h1>{{theTime}}</h1>
</div>
<p>The $interval service runs a function every specified millisecond.</p>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $interval) {
$scope.theTime = new Date().toLocaleTimeString();
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
});
</script>
</body>
</html>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 298 | CSS |
선택과집중
|
1개월 전 | 146 | |
| 297 | CSS |
선택과집중
|
3개월 전 | 351 | |
| 296 | CSS |
선택과집중
|
3개월 전 | 298 | |
| 295 | CSS |
선택과집중
|
3개월 전 | 275 | |
| 294 | CSS |
선택과집중
|
3개월 전 | 399 | |
| 293 | CSS |
선택과집중
|
4개월 전 | 337 | |
| 292 | CSS |
선택과집중
|
4개월 전 | 270 | |
| 291 | CSS |
선택과집중
|
4개월 전 | 278 | |
| 290 | CSS |
선택과집중
|
4개월 전 | 317 | |
| 289 | CSS |
선택과집중
|
4개월 전 | 294 | |
| 288 | CSS |
선택과집중
|
4개월 전 | 381 | |
| 287 | CSS |
선택과집중
|
4개월 전 | 335 | |
| 286 | CSS |
선택과집중
|
5개월 전 | 335 | |
| 285 | CSS |
선택과집중
|
5개월 전 | 352 | |
| 284 | CSS |
선택과집중
|
5개월 전 | 240 | |
| 283 | CSS |
|
2년 전 | 1511 | |
| 282 | CSS | 2년 전 | 2483 | ||
| 281 | CSS | 4년 전 | 4014 | ||
| 280 | CSS | 4년 전 | 4542 | ||
| 279 | 반응형웹 | 5년 전 | 2969 | ||
| 278 | 반응형웹 | 5년 전 | 2809 | ||
| 277 | 부트스트랩 | 7년 전 | 5015 | ||
| 276 | 부트스트랩 | 7년 전 | 6570 | ||
| 275 | 부트스트랩 | 7년 전 | 4651 | ||
| 274 | 부트스트랩 | 7년 전 | 6683 | ||
| 273 | 부트스트랩 | 7년 전 | 3351 | ||
| 272 | 부트스트랩 | 7년 전 | 3193 | ||
| 271 | 부트스트랩 | 7년 전 | 3692 | ||
| 270 | 부트스트랩 | 7년 전 | 3214 | ||
| 269 | 부트스트랩 | 7년 전 | 3084 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기