nglink 在 angular 1.5 的 phantomjs 组件测试中不起作用
nglink not working in phantomjs component test for angular 1.5
我有一个导航栏组件:
.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: 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
我如何更正它以使其通过 ng-link
根据 the documention for the component router,指令是 router-link
,而不是 ng-link
(即使它被称为 ngLink)。
经过我的搜索,我意识到不是我的代码有问题,而是 Phantomjs 与 es6 不兼容。解决方案是升级到 Phantomjs2 或添加 polyfill; here is a fantastic article on that
我有一个导航栏组件:
.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: 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
我如何更正它以使其通过 ng-link
根据 the documention for the component router,指令是 router-link
,而不是 ng-link
(即使它被称为 ngLink)。
经过我的搜索,我意识到不是我的代码有问题,而是 Phantomjs 与 es6 不兼容。解决方案是升级到 Phantomjs2 或添加 polyfill; here is a fantastic article on that