用茉莉花进行单元测试

时间:2016-08-11 11:31:29

标签: angularjs angularjs-directive module dependencies directive

我在角应用程序中工作,我想实现一个表格排序系统 这是我的ui-table-sort.js

(function() {
    'use strict';
    var dependencies = [];
    angular.module('uiTable', dependencies)
        .config(configFn)
        .run(runFn)
        .directive('uiTableSorted',[uiTableSortedDirective])
    function uiTableSortedDirective() {
        return {
         restrict: 'A',
         transclude: true,
         template : 
           '<a ng-click="onClick()">'+
           '<span ng-transclude></span>'+ 
           '<i class="glyphicon" ng-class="{\'glyphicon-sort-by-alphabet\' : order === by && !reverse,  \'glyphicon-sort-by-alphabet-alt\' : order===by && reverse}"></i>'+
           '</a>',
         scope: {
                order: '=',
                 by: '=',
            reverse : '='
      },
       link: function(scope, el, attr, ctrl) {
      scope.onClick = function () {
        if( scope.order === scope.by ) {
           scope.reverse = !scope.reverse 
        } else {
          scope.by = scope.order ;
          scope.reverse = false; 
        }
      }
    }
   }
  }
})();

此文件用于其他控制器&#39; entity-list.js:

(function() {
'use strict';
var dependencies = ['uiTable','core'];
angular.module('entityList', dependencies)
    .config(configFn)
    .run(runFn)
    .directive('entityList', ['BASE_PATH', entityListDirective])
    .controller('EntityListCtrl', ['$scope','Entity', EntityListCtrl])
function EntityListCtrl($scope  , Entity ) {
    $scope.order = 'id';
    $scope.reverse = false;
    $scope.eltsPerPage = 50
    $scope.entityList = [];
    $scope.offset = 0;
    $scope.totalCount = 0;
    var self = $scope;
    $scope.edit = editFn;
    $scope.delete = deleteFn
    $scope.view = viewFn

这是视图

<div ng-controller="EntityListCtrl">
<table class="table o-responsive-table table-hover">
    <caption></caption>
    <thead class="cf">
        <tr> 
            <th scope="col" class="header" uiTableSorted order="id" by="order" reverse="reverse" >#</th>
        </tr>

问题是我的指令uiTableSorted没有添加到视图中的元素,是否有任何依赖问题 我关注此链接plunker

0 个答案:

没有答案