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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 268 | 부트스트랩 | 8년 전 | 3141 | ||
| 267 | 부트스트랩 | 8년 전 | 2925 | ||
| 266 | 부트스트랩 | 8년 전 | 2914 | ||
| 265 | 부트스트랩 | 8년 전 | 3406 | ||
| 264 | 부트스트랩 | 8년 전 | 3149 | ||
| 263 | 부트스트랩 | 8년 전 | 3223 | ||
| 262 | 부트스트랩 | 8년 전 | 2723 | ||
| 261 | 부트스트랩 | 8년 전 | 4844 | ||
| 260 | 부트스트랩 | 8년 전 | 3217 | ||
| 259 | 부트스트랩 | 8년 전 | 2762 | ||
| 258 | 부트스트랩 | 8년 전 | 2788 | ||
| 257 | 부트스트랩 | 8년 전 | 2814 | ||
| 256 | 부트스트랩 | 8년 전 | 3304 | ||
| 255 | 부트스트랩 | 8년 전 | 3493 | ||
| 254 | 부트스트랩 | 8년 전 | 3227 | ||
| 253 | 부트스트랩 | 8년 전 | 4104 | ||
| 252 | 부트스트랩 | 8년 전 | 2890 | ||
| 251 | 부트스트랩 | 8년 전 | 2613 | ||
| 250 | 부트스트랩 | 8년 전 | 2717 | ||
| 249 | 부트스트랩 | 8년 전 | 2427 | ||
| 248 | 부트스트랩 | 8년 전 | 1973 | ||
| 247 | 부트스트랩 | 8년 전 | 1730 | ||
| 246 | 부트스트랩 | 8년 전 | 2001 | ||
| 245 | 부트스트랩 | 8년 전 | 1522 | ||
| 244 | 부트스트랩 | 8년 전 | 2140 | ||
| 243 | 부트스트랩 | 8년 전 | 1894 | ||
| 242 | 부트스트랩 | 8년 전 | 1783 | ||
| 241 | 부트스트랩 | 8년 전 | 1171 | ||
| 240 | 부트스트랩 | 8년 전 | 1622 | ||
| 239 | 부트스트랩 | 8년 전 | 1652 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기