2015-02-06 67 views
0

我有这样的代码dotdotdot插件分析的角度表达了评估之前

<div ng-app="m" ng-controller="a"> 
     <div d style="width:100px;height:200px" > 
      {{customer.name}} 
      <p>Lorem Ipsum is simply dummy text. Lorem Ipsum is simply dummy textLorem Ipsum is simply dummy textLorem Ipsum is simply dummy textLorem Ipsum is simply dummy textLorem Ipsum is simply dummy textLorem Ipsum is simply dummy text</p> 
     </div> 
    </div> 

这里是JS代码

var b = angular.module('m', []).controller('a', function ($scope) { 
    $scope.customer = { 
     name: 'Aby' 
    } }); b.directive('d', function() { 
    return { 
     retistric: 'A', 
     link: function ($scope, element, attributes) { 
      $(element).dotdotdot({ 
       /* The text to add as ellipsis. */ 
       'ellipsis': '... ', 

       /* jQuery-selector for the element to keep and put after the ellipsis. */ 
       'after': null, 

       /* Whether to update the ellipsis: true/'window' */ 
       'watch': true, 

       /* Optionally set a max-height, if null, the height will be measured. */ 
       'height': null, 

       /* Callback function that is fired after the ellipsis is added, 
        receives two parameters: isTruncated(boolean), orgContent(string). */ 
       'callback': attributes["callback"], 
      }); 

     } 
    }; 
    }); 

这里是出放

{{customer.name}} Lorem Ipsum is simply dummy text. Lorem Ipsum is simply dummy textLorem Ipsum is... 

这里dotdotdot呼叫看到作为字符串的angularjs表达式。我如何确保在插件执行之前评估表达式?

回答

0

尝试更改链接以在指令中编译。

var b = angular.module('m', []).controller('a', function ($scope) { 
    $scope.customer = { 
    name: 'Aby' 
    } }); b.directive('d', function() { 
    return { 
    retistric: 'A', 
    compile: function (element, attributes) { 
     return { 
     post: function ($scope, element) { 
      $(element).dotdotdot({ 
      /* The text to add as ellipsis. */ 
      'ellipsis': '... ', 

      /* jQuery-selector for the element to keep and put after the ellipsis. */ 
      'after': null, 

      /* Whether to update the ellipsis: true/'window' */ 
      'watch': true, 

      /* Optionally set a max-height, if null, the height will be measured. */ 
      'height': null, 

      /* Callback function that is fired after the ellipsis is added, 
      receives two parameters: isTruncated(boolean), orgContent(string). */ 
      'callback': attributes["callback"] 
      }); 
     } 
     } 
    } 
    } 
});