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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 88 | jQuery Mobile | 8년 전 | 1938 | ||
| 87 | jQuery Mobile | 8년 전 | 1919 | ||
| 86 | jQuery Mobile | 8년 전 | 1529 | ||
| 85 | jQuery Mobile | 8년 전 | 1837 | ||
| 84 | jQuery Mobile | 8년 전 | 1874 | ||
| 83 | jQuery Mobile | 8년 전 | 1887 | ||
| 82 | jQuery Mobile | 8년 전 | 1658 | ||
| 81 | jQuery Mobile | 8년 전 | 1375 | ||
| 80 | jQuery Mobile | 8년 전 | 1812 | ||
| 79 | jQuery Mobile | 8년 전 | 1360 | ||
| 78 | jQuery Mobile | 8년 전 | 1757 | ||
| 77 | jQuery Mobile | 8년 전 | 1783 | ||
| 76 | jQuery Mobile | 8년 전 | 1791 | ||
| 75 | jQuery Mobile | 8년 전 | 1405 | ||
| 74 | jQuery Mobile | 8년 전 | 1543 | ||
| 73 | jQuery Mobile | 8년 전 | 1250 | ||
| 72 | jQuery Mobile | 8년 전 | 1630 | ||
| 71 | jQuery Mobile | 8년 전 | 1623 | ||
| 70 | jQuery Mobile | 8년 전 | 1507 | ||
| 69 | jQuery Mobile | 8년 전 | 1515 | ||
| 68 | jQuery Mobile | 8년 전 | 2051 | ||
| 67 | jQuery Mobile | 8년 전 | 1319 | ||
| 66 | jQuery Mobile | 8년 전 | 1695 | ||
| 65 | jQuery Mobile | 8년 전 | 1188 | ||
| 64 | jQuery Mobile | 8년 전 | 1469 | ||
| 63 | jQuery Mobile | 8년 전 | 1659 | ||
| 62 | jQuery Mobile | 8년 전 | 1644 | ||
| 61 | jQuery Mobile | 8년 전 | 1878 | ||
| 60 | jQuery Mobile | 8년 전 | 1412 | ||
| 59 | jQuery Mobile | 8년 전 | 1968 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기