Angular.js: هل سيبقى $$ tlb / رسميًا؟

تم إنشاؤها على ٢٩ يناير ٢٠١٤  ·  3تعليقات  ·  مصدر: angular/angular.js

نظرًا لأنه غير موجود في المستندات ، فأنا أحذر قليلاً من استخدامه في توجيهاتي.

ومع ذلك ، فأنا في حاجة إلى استخدامه ، حيث أود أن أكون قادرًا على القيام بالعديد من التضمين في بعض الحالات.

إذن ها هو هل يمكنني استخدامه بأمان دون خوف من رؤية توجيهاتي تنكسر في المستقبل؟

التعليق الأكثر فائدة

هل سيكون هناك نوع من الخيارات للسماح بالتضمين المتعدد لنفس العنصر في المستقبل؟
أستطيع أن أرى العديد من المجالات حيث سيكون هذا مفيدًا - إنه في الواقع مهم جدًا لبعض التوجيهات الخاصة بي ، حيث تم اختزالتي في العبث بـ DOM و compile $ في وظيفة الترجمة (والتي لا تبدو نظيفة tbh)

ال 3 كومينتر

من فضلك لا تعتمد على واجهة برمجة التطبيقات هذه. يعني $$ أنه خاص ويمكننا كسره في إصدار مستقبلي.

هل سيكون هناك نوع من الخيارات للسماح بالتضمين المتعدد لنفس العنصر في المستقبل؟
أستطيع أن أرى العديد من المجالات حيث سيكون هذا مفيدًا - إنه في الواقع مهم جدًا لبعض التوجيهات الخاصة بي ، حيث تم اختزالتي في العبث بـ DOM و compile $ في وظيفة الترجمة (والتي لا تبدو نظيفة tbh)

سيكون من المفيد بالتأكيد أن تكون قادرًا على تنفيذ سلوك نمط ngIf في التوجيهات المخصصة. نقوم بإنشاء مثل هذه التوجيهات بحيث لا نضطر باستمرار إلى حقن الخدمات وإنشاء خصائص وحدة التحكم لغرض عرض العنصر فقط.

أنا بالتأكيد أفضل عدم الاضطرار إلى الاعتماد على خاصية التوجيه الداخلي لجعلها تعمل مثل ngIf.

على سبيل المثال:

import {SubscriptionService, ISubscription} from '../subscriptions/subscriptions.service';

interface IPBIfFeatureDirectiveScope extends ng.IScope {
  isRenderElement: boolean;
}

interface IPBIfFeatureDirectiveAttributes extends ng.IAttributes {
  pbIfFeature: string;
  ngIf: string;
}

class IfFeatureDirective implements ng.IDirective {

  public transclude: any;
  public priority: number;
  public terminal: boolean;
  public restrict: string;
  public scope = true;
  public link: ng.IDirectiveLinkFn;
  public $$tlb: boolean;

  constructor(ngIfDirectiveArr: ng.IDirective[],
              subscriptionService: SubscriptionService,
              $parse: ng.IParseService) {

    let ngIfDirective: any = ngIfDirectiveArr[0];

    this.transclude = ngIfDirective.transclude;
    this.priority = ngIfDirective.priority - 1;
    this.terminal = ngIfDirective.terminal;
    this.restrict = ngIfDirective.restrict;
    this.$$tlb = true;
    this.link = function (scope: IPBIfFeatureDirectiveScope,
                          element: ng.IAugmentedJQuery,
                          attr: IPBIfFeatureDirectiveAttributes) {
      let expression: string = attr.pbIfFeature;
      let argArray: IArguments = arguments;
      let executeDirective = (): void => {
        subscriptionService.getSubscription().$promise
          .then((subscription: ISubscription) => {
            scope.isRenderElement = $parse(expression)(subscription.features);
            attr.ngIf = 'isRenderElement';
            ngIfDirective.link.apply(null, argArray);
          });
      };
      executeDirective();
    };
  }
}
export const ifFeatureDirectiveFactory = (ngIfDirective: ng.IDirective[],
                                          subscriptionService: SubscriptionService,
                                          $parse: ng.IParseService): ng.IDirective => new IfFeatureDirective(ngIfDirective, subscriptionService, $parse);
ifFeatureDirectiveFactory.$inject = ['ngIfDirective', 'subscriptionService', '$parse'];
هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات