简体   繁体   English

nglink无法在phantomjs组件测试中使用angular 1.5

[英]nglink not working in phantomjs component test for angular 1.5

I have a navbar component: 我有一个导航栏组件:

 .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> 

The test runs fine without the ng-link="['NewStockCount']" but if i add it fails with an error 没有ng-link="['NewStockCount']"情况下测试运行正常,但是如果我添加,它将失败并显示错误

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

how do i correct this to make it pass with ng-link 我如何纠正这个问题以使其通过ng-link

根据有关组件路由器的文档 ,该指令是router-link ,而不是ng-link (即使它称为ngLink)。

Well after my search i realized it wasn't my code that have the issue but Phantomjs is not compatible with es6 yet. 在搜索之后,我意识到不是我的代码有问题,但是Phantomjs尚未与es6兼容。 the solutions is to either bump up to Phantomjs2 or add polyfills; 解决方案是提高Phantomjs2或添加polyfill; here is a fantastic article on that 这是一篇很棒的文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM