Tôi có một chỉ thị tùy chỉnh như thế này:
myApp.directive('input', function() {
return {
restrict: 'E',
scope: true,
link: function (scope, elem) {
if (scope.lang && elem.attr('type') === 'text') {
elem.attr('lang', 'fa');
console.log(scope.lang);
}
}
};
});
mà thêm lang='fa'
thuộc tính cho tất cả các đầu vào: văn bản và tôi cũng đang sử dụng DatePicker angular Ui nhưng tôi nhận được một lỗi:
Error:
[$compile:multidir] Multiple directives [datepickerPopupPersian, input] asking for
new/isolated scope on:
<input type="date" name="birth" class="form-control ng-pristine
ng-untouched ng-valid"
datepicker-popup-persian="{{formats.ShowDate}}" tabindex="7"
ng-model="requesterViewModel.BirthDate"
is-open="datePicker.opened" datepicker-options="dateOptions" date-disabled="disabled(date, mode)"
close-text="بسته"
max-date="dt">
khi tôi nhận xét ngàyPicker trong biểu mẫu của tôi, mọi thứ hoạt động tốt.
Bất kỳ ý tưởng nào? Cảm ơn
Chỉ thị của bạn không thực sự cần phạm vi; thử sử dụng 'scope: false'. –
Xin chào giáo viên của tôi :), bạn đã lưu ngày hôm qua, khi tôi xóa nó, chỉ thị tùy chỉnh không hoạt động bởi vì trong bộ điều khiển của tôi, tôi đã thêm điều này: $ scope.lang = 'faLang'; – sani
:) Nếu bạn vô hiệu hóa chỉ thị 'input' của bạn (hoàn toàn bình luận ra mã), vấn đề có tồn tại không? –