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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 208 | 부트스트랩 | 8년 전 | 2722 | ||
| 207 | AngularJS | 8년 전 | 1464 | ||
| 206 | AngularJS | 8년 전 | 1112 | ||
| 205 | AngularJS | 8년 전 | 986 | ||
| 204 | AngularJS | 8년 전 | 1387 | ||
| 203 | AngularJS | 8년 전 | 1184 | ||
| 202 | AngularJS | 8년 전 | 1499 | ||
| 201 | AngularJS | 8년 전 | 1449 | ||
| 200 | AngularJS | 8년 전 | 1423 | ||
| 199 | AngularJS | 8년 전 | 1346 | ||
| 198 | AngularJS | 8년 전 | 1227 | ||
| 197 | AngularJS | 8년 전 | 1391 | ||
| 196 | AngularJS | 8년 전 | 1044 | ||
| 195 | AngularJS | 8년 전 | 1256 | ||
| 194 | AngularJS | 8년 전 | 1267 | ||
| 193 | AngularJS | 8년 전 | 1613 | ||
| 192 | AngularJS | 8년 전 | 1359 | ||
| 191 | AngularJS | 8년 전 | 1586 | ||
| 190 | AngularJS | 8년 전 | 1551 | ||
| 189 | AngularJS | 8년 전 | 1642 | ||
| 188 | AngularJS | 8년 전 | 1397 | ||
| 187 | AngularJS | 8년 전 | 1368 | ||
| 186 | AngularJS | 8년 전 | 1401 | ||
| 185 | AngularJS | 8년 전 | 1439 | ||
| 184 | AngularJS | 8년 전 | 1478 | ||
| 183 | AngularJS | 8년 전 | 1474 | ||
| 182 | AngularJS | 8년 전 | 1008 | ||
| 181 | AngularJS | 8년 전 | 1386 | ||
| 180 | AngularJS | 8년 전 | 1277 | ||
| 179 | AngularJS | 8년 전 | 1253 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기