I는 다음과 같이 정의 지시어는 다음 한 : 그것은 the DatePicker section here에서 가져옵니다 및 예상되는AngularJS와 UI 부트 스트랩 DatePicker에서가 작동하지 올바르게
//TypeScript
module MyApp.Directives {
/** Scope for Messaging directive. */
export interface IMaDatePickerScope extends ng.IScope {
dt: Date;
today(): void;
clear(): void;
disabled(date, mode): boolean;
open($event): void;
opened: boolean;
dateOptions;
formats: string[];
format: string;
}
export class MaDatePicker implements ng.IDirective {
restrict = "E";
templateUrl = TEMPLATES + 'ma-date-picker.html';
replace = true;
transclude = true;
scope = {
labelText: '@',
datePickerId: '='
}
link = (scope: IMaDatePickerScope) => {
scope.today =() => {
scope.dt = new Date();
}
scope.today();
scope.clear =() => {
scope.dt = null;
}
scope.disabled = (date: Date, mode) => {
return (mode == 'day' && (date.getDay() === 0 || date.getDay() === 6)); //disable Saturday and Sunday
}
scope.open = ($event) => {
$event.preventDefault();
$event.stopPropagation();
scope.opened = true;
}
scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
}
scope.formats = ['yyyy-MM-dd', 'dd-MMMM-yy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
scope.format = scope.formats[0];
}
controller = ($scope: IMaDatePickerScope) => {
}
}
}
템플릿
<div class="date-picker">
<div class="row">
<div class="col-md-6">
<label for="{{datePickerId}}">{{labelText}}</label>
<p class="input-group">
<input type="text"
id="{{datePickerId}}"
class="form-control"
datepicker-popup="{{format}}"
ng-model="dt"
is-open="opened"
datepicker-options="dateOptions"
disabled="disabled"
ng-required="true"
close-text="Close" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
</div>
</div>
지침 해당 페이지에 표시된 팝업 버전과 같은 기능을합니다. 그러나 캘린더 버튼을 클릭하여 지침을 시작할 때마다 캘린더는 깨진 방식으로 나타납니다. 또한 캘린더는 팝업 캘린더에서 '다음 달'화살표를 클릭하면 왼쪽으로 확장됩니다. 내 코드에 문제가 있습니까? 나는이 사이트에 어떤 스타일도없는 것처럼 보이기 때문에 어떤 스타일링도 추가하지 않았지만, 기존의 스타일링을 분해하기 전에 코드에 분명히 잘못된 것이 있는지 확인하고 싶었습니다.
사용중인 라이브러리 버전은 무엇입니까? –
각도 v1.2.16 각도 UI 부트 스트랩 0.11.0 – muttley91
ui-bootstrap 외에 ui-bootstrap-tpls 파일도 포함 시켰습니까? – Ken