반응형
dateFilter란 무엇이며 자세한 내용은 어디에서 확인할 수 있습니까?
지시사항에 대한 Angular 문서 http://docs.angularjs.org/guide/directive 를 검토하고 있습니다.
페이지의 예시 중 하나(여기 http://jsbin.com/osOQOYag/3/edit?html,js,output 에서 전체 작동 예시)
angular.module('docsTimeDirective', [])
.controller('Ctrl2', function($scope) {
$scope.format = 'M/d/yy h:mm:ss a';
})
.directive('myCurrentTime', function($interval, dateFilter) {
function link(scope, element, attrs) {
var format,
timeoutId;
function updateTime() {
element.text(dateFilter(new Date(), format));
}
scope.$watch(attrs.myCurrentTime, function(value) {
format = value;
updateTime();
});
element.on('$destroy', function() {
$interval.cancel(timeoutId);
});
// start the UI update process; save the timeoutId for canceling
timeoutId = $interval(function() {
updateTime(); // update DOM
}, 1000);
}
return {
link: link
};
});
통화 중:
.directive('myCurrentTime', function($interval, dateFilter) {
.directive prototype에 대한 정보를 찾을 수 없고 dateFilter에 대한 문서도 찾을 수 없습니다.또한, AngularJS의 Unminized 버전에서 dateFilter가 발견된다는 것을 알고 있습니다(minized 버전에서는 이름이 사라지지만).dateFilter 및 유사한 기능에 대해 설명하는 몇 가지 지침(및 링크)을 제공할 수 있는 사람이 있습니까?
날짜 필터 문서는 여기에 있습니다.
다음은 필터 주입을 설명하는 문서의 일부입니다. http://code.angularjs.org/1.2.5/docs/guide/filter#using-filters-in-controllers-and-services
필터는 일반적으로 뷰 표현식에 사용됩니다({{myDate | date:'short'}}), 하지만 JS 코드에서도 사용할 수 있습니다.필터는 문자열을 추가하여 주입합니다.Filter필터 이름(예:date->dateFilter).
app.controller('MyCtrl', function($scope, dateFilter, lowercaseFilter){
$scope.myDate = new Date();
$scope.myDateFormatted = dateFilter($scope.myDate, 'shortDate');
$scope.myString = 'Some String';
$scope.myStringLowerCased = lowercaseFilter($scope.myString);
});
언급URL : https://stackoverflow.com/questions/20788773/what-is-datefilter-and-where-can-i-find-out-more-about-it
반응형
'programing' 카테고리의 다른 글
| ASP에 개별 사용자 계정 인증 옵션이 없습니다.NET Core 웹 API 템플릿 (0) | 2023.11.06 |
|---|---|
| jQuery $(문서).준비() 두 번 발사 (0) | 2023.11.06 |
| 배열의 두 번째에서 마지막 항목을 얻습니까? (0) | 2023.11.06 |
| Oracle이 Docker에서 작동하는지 확인하려면 어떻게 해야 합니까? (0) | 2023.11.06 |
| 이 오류는 무엇을 의미합니까? 'somefile.c:200: error: 1032바이트의 프레임 크기가 1024바이트보다 큽니다.' (0) | 2023.11.06 |