0

这是我的测试文件:

describe('Clinical App', function() {

  var  template, element;

  beforeEach(module('clinicalApp'));

  describe('clinicalHeader', function() {
    beforeEach(module('app/views/header.html'));

    beforeEach(inject(function($templateCache, $compile, $rootScope) {
      template = $templateCache.get('app/views/header.html');
      $templateCache.put('views/header.html', template);
      var directive = angular.element('<clinical-header></clinical-header>');
      element = $compile(directive)($rootScope);
      $rootScope.$digest();
    }));

    it('should have a list of links', function() {
      var links = element.find('a');
      expect(links.length).toBe(4);
    });
  });
});

我不断收到Error: [$compile:multidir] Multiple directives [clinicalHeader, clinicalHeader] asking for template on:错误消息。我看不到我在哪里加载了 2 次。有人可以看看吗?

4

1 回答 1

0

这个问题无法回答,因为你没有所有的信息。我有一份我正在测试的指令的副本隐藏在控制器文件夹中。当应用程序加载时,它也在加载指令的额外副本。因此,我得到了一个多指令错误。

于 2013-10-24T09:57:46.270 回答