nglink没有在角度1.5的phantomjs组件测试中工作

时间:2016-04-11 23:04:33

标签: javascript angularjs phantomjs angularjs-1.5 ngcomponentrouter

我有一个导航栏组件:

.component('navbar', {
      templateUrl: 'app/common/navbar/navbar.html',
      controller: NavbarController,
      bindings: {
        state: '<',
        weekLabel: '<'
      }
    })

  /** @ngInject */
  function NavbarController () {
  }
<div class="header">
  <h3 class="text-muted">
    Vaccine Stock Dashboard
    <span ng-if="$ctrl.state"> - </span>
    <span class="qa-state-label" ng-bind="$ctrl.state | uppercase"></span>
    <span ng-if="$ctrl.weekLabel"> - </span>
    <span class="qa-week-label" ng-bind="$ctrl.weekLabel"></span>
    <a class="pull-right" ng-link="['NewStockCount']">
      <i class="fa fa-plus"></i>
      Add Stock Count
    </a>
  </h3>
</div>

测试在没有ng-link="['NewStockCount']"的情况下运行良好,但是如果我添加它会失败并显示错误

  

ReferenceError:找不到变量:Map(第2166行)       RouteRegistry@/home/femi/fielded/nav-integrated-state-dashboard/bower_components/bower-angular-router/angular1/angular_1_router.js:2166:30

如何更正此问题以使其通过ng-link

2 个答案:

答案 0 :(得分:1)

According to the documention for the component router, the directive is router-link, not ng-link (even though it's called ngLink).

答案 1 :(得分:0)

在我的搜索后,我意识到这不是我的代码有问题,但Phantomjs与es6不兼容。解决方案是要么碰到Phantomjs2还是添加polyfill; here is a fantastic article on that