我试图通过npm在Windows上安装PhantomJS 1.8.1-3.无论我做什么,它似乎都会失败.这是我正在运行的命令:
npm install phantomjs
Run Code Online (Sandbox Code Playgroud)
执行该命令后,它失败并出现以下错误:
> phantomjs@1.8.1-3 install c:\johnprojects\tablet\htdocs\mini-app-sandbox\node_
modules\grunt-contrib-qunit\node_modules\grunt-lib-phantomjs\node_modules\phanto
mjs
> node install.js
Requesting c:\johnprojects\tablet\htdocs\mini-app-sandbox\node_modules\grunt-con
trib-qunit\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\tmp\phantomjs
-1.8.1-windows.zip
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:770:11)
at Object.afterConnect [as oncomplete] (net.js:761:19)
npm ERR! phantomjs@1.8.1-3 install: `node install.js`
npm ERR! `cmd "/c" "node install.js"` failed with 1
npm ERR!
npm ERR! Failed at the phantomjs@1.8.1-3 install script.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm …Run Code Online (Sandbox Code Playgroud) 当我尝试使用yeoman web生成器时,虽然它正在工作,但是通过查看整个生成进度,它总是在下面给我一些错误,无论我使用什么生成器,它们总是在那里.
npm ERR! phantomjs@1.9.7-6 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs@1.9.7-6 install script.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls phantomjs
npm ERR! There is likely additional logging output above.
npm …Run Code Online (Sandbox Code Playgroud) 我从angular-ui-router获得以下错误:
TypeError: Cannot read property '@' of null
...
TypeError: Cannot read property '@main' of null
...
Run Code Online (Sandbox Code Playgroud)
我已经对可能导致此错误的原因进行了一些研究,并得出结论,问题在于我在onEnter期间通过$ state.go(state)在条件为false时进行重定向另一个州
以下是关于github上同一问题的一些讨论:
我尝试了一些建议,但它们没有用.他们似乎没有提供解决方案,但只是指出问题,并根据这个 github讨论它应该解决,但我似乎无法让它工作.
我使用的是AngularJS v1.2.24和ui-router v0.2.11.
使用以下代码(简化):
.state('main', {
abstract: true,
url: '/main',
templateUrl: '/main/_layout.html'
})
.state('main.home', {
url: '/home',
templateUrl: '/main/home/home.html',
controller: 'HomeCtrl',
onEnter: function ($state)
{
if (condition === true){
$state.go('main.catch')
}
}
})
.state('main.catch', {
url: '/catch',
templateUrl: '/main/catch/catch.html',
controller: 'CatchCtrl'
})
Run Code Online (Sandbox Code Playgroud)
有没有办法让这个工作?或者我应该考虑一种完全不同的方法来实现相同的结果?
PS:可能的解决方法是在控制器中执行以下操作,
$scope.$on('$stateChangeSuccess', function(){
// conditional redirect here
}
Run Code Online (Sandbox Code Playgroud)
但我不想在HomeCtrl中这样做.