Sad*_*yan 5 angularjs angular-directive
我有这样的自定义指令:
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);
}
}
};
});
Run Code Online (Sandbox Code Playgroud)
添加lang='fa'属性到所有输入:文本,我也使用DatePicker角度Ui但我得到一个错误:
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">
Run Code Online (Sandbox Code Playgroud)
当我在我的表单中评论datePicker一切正常.
任何的想法?谢谢
该指令实际上并不需要新的子范围(既不是孤立的).配置它要好得多scope: false.它不仅可以纠正这个问题,还可以保存几个(当然是视图的设计)不必要的范围对象创建.
| 归档时间: |
|
| 查看次数: |
14700 次 |
| 最近记录: |