如何调用angularjs指令?

时间:2016-01-18 10:08:45

标签: javascript angularjs

我试图理解caitp angular comment system没有太多运气,并且想知道是否有人可以帮助我。

有一个名为directive的评论,如下所示:

public class ViewFieldGroup : DependencyObject
{

public static readonly DependencyProperty DataObjectProperty = DependencyProperty.Register(
  "DataObject", typeof(object), typeof(ViewFieldGroup),
  new FrameworkPropertyMetadata(null, new PropertyChangedCallback(DataObject_PropertyChanged)));

private static void DataObject_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
  // do stuff
}

我相信调用该指令的代码是:

.directive('comments', function($compile, $interpolate, commentsConfig) {
  return {
    restrict: 'EA',
    require: '?^comment',
    transclude: true,
    replace: true,
    templateUrl: function() { return commentsConfig.containerTemplate; },
    scope: {
      'comments': '=commentData'
    }, 
    controller: function() {},
    link: {
      pre: function(scope, elem, attr, comment) {
        var self = elem.controller('comments'),
             parentCollection = comment ? comment.comments : null;

    // Setup $commentsController
    if (parentCollection) {
      self.commentsDepth = parentCollection.commentsDepth + 1;
      self.commentsRoot = parentCollection.commentsRoot;
      self.commentsParent = parentCollection;
    } else {
      self.commentsDepth = 1;
      self.commentsRoot = null;
      var depthLimit = angular.isDefined(attr.commentDepthLimit) ?
                       attr.commentDepthLimit :
                       commentsConfig.depthLimit;
      if (typeof depthLimit === 'string') {
        depthLimit = $interpolate(depthLimit, false)(scope.$parent);
        if (typeof depthLimit === 'string') {
          depthLimit = parseInt(depthLimit, 10);
        }
      }

      if (typeof depthLimit !== 'number' || depthLimit !== depthLimit) {
        // Avoid NaN and non-numbers
        depthLimit = 0;
      }

      self.commentsDepthLimit = depthLimit;
    }

        scope.commentsDepth = self.commentsDepth;
        attr.$observe('orderBy', function(newval, oldval) {
          scope.commentOrder = newval || commentsConfig.orderBy;
        });
      }
    }
  };
})

我的问题是:对于指令中的链接前置函数,发送的输入参数在哪里?评论的价值在哪里设定?

0 个答案:

没有答案