以上就是给各位分享angularjs–量角器无法使用directConnect运行,其中也会对安卓量角器进行解释,同时本文还将给你拓展AngualrJS中的Directive制作一个菜单_Angula
以上就是给各位分享angularjs – 量角器无法使用directConnect运行,其中也会对安卓量角器进行解释,同时本文还将给你拓展AngualrJS中的Directive制作一个菜单_AngularJS、AngularJs Directive Pass value/object/function to Scope、angularjs directive 的几点使用技巧、AngularJs directive-controller实例等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- angularjs – 量角器无法使用directConnect运行(安卓量角器)
- AngualrJS中的Directive制作一个菜单_AngularJS
- AngularJs Directive Pass value/object/function to Scope
- angularjs directive 的几点使用技巧
- AngularJs directive-controller实例
angularjs – 量角器无法使用directConnect运行(安卓量角器)
当我使用directConnect:true运行量角器时,我得到:
Using ChromeDriver directly…
[launcher] Running 1 instances of
WebDriver Error: spawn ENOENT
at errnoException (child_process.js:1001:11)
at Process.ChildProcess._handle.onexit (child_process.js:792:34) [launcher] Process exited with error code 1
如果我在没有directConnect的情况下运行量角器而是指定我的selenium url,一切运行正常.
我正在运行Protractor版本1.6.1,Chrome版本41.0.2272.35 beta-m(64位)和Chromedriver版本2.13.0.
解决方法
我有同样的问题并通过改变protractor-conf.js中的chromeDriver路径设置来解决它,具体取决于我是在Windows还是OSX / Linux上.
下面的解决方案和说明假设您正在使用npm install chromedriver提供的chromedriver.此解决方案也适用于量角器3.2.2和chromedriver 2.21.2.
Protractor chromedriver在OSX和Linux上工作,但我在Windows上遇到了ENOENT错误.我已经提交了一个问题here并且还记录了一个解决方法.
问题(我认为)是childProcess.spawn在Windows上有问题(请参阅问题列表here),并且当通过childProcess.spawn调用时,node_modules / chromedriver / bin / chromedriver文件将无法正确运行 – 可能因为此文件不是可执行文件和Windows不知道使用节点二进制文件来解释文件.
解决方法是在Windows上运行时提供Windows可执行文件的路径.如下所示,在protractor-conf.js中改变chromeDriver arg是很容易的 – 尽管是hackish:
所有三个操作系统的protractor-conf.js:
var chromeDriverPath = process.platform === 'win32' ? 'node_modules/chromedriver/lib/chromedriver/chromedriver.exe' : 'node_modules/chromedriver/bin/chromedriver'; exports.config = { directConnect: true,chromeDriver: chromeDriverPath,specs: [ 'features/*.feature' ],capabilities: { browserName: 'chrome',platform: 'ANY',chromeOptions: { args: ['--test-type'] } } }
希望这可以帮助.
AngualrJS中的Directive制作一个菜单_AngularJS
说下我经常写菜单的方式:
<ul> <li data-ng-> <a href="#/orders">Orders</a> </li> </ul>
菜单项是否高亮显示取决于controller中的highlight方法。
vm.highlight = funciton(path){ return $locaiton.path().substr(0, path.lenght) === path; }
如果以Directive的方式会更简洁。
<ul menu-highlighter highlight-class-name="active"> <li><a href="#/customers">Customers</a></li> <li><a href="#/orders">Customers</a></li> <li><a href="#/about">Customers</a></li> </ul>
Directive大致是:
(function(){ var injectParams = [''$location'']; var menuHighlighter = function($location){ var link = function(scope, element){ function setActive(){ var path = $location.path(); var className = scope.highlightClassName || ''active''; if(path){ angular.forEac(element.find(''li''), function(li){ //<a href="#/customers">Customers</a> var anchor = li.querySelector(''a''); //#/customers var href=(anchor && anchor.href) ? anchor.href : anchor.getAttribute(''data-href'').replace(''#'',''''); //customers var trimmedHref = href.substr(href.indexOf(''#/'')+1, href.length); var basePath = path.substr(0, trimmedHref.length); if(trimmedHref === basePath){ angular.element(li).addClass(className); } else { angular.element(li).removeClass(className); } }); } } setActive(); scope.$on(''$locationChangeSuccess'', setActive); }; return { restrict: ''A'', scope: { highlightClassName: ''@'' }, link: link } }; menuHighlighter.$inject = injectParams; angular.module(''my.directives'') .directive(''menuHighlighter'', menuHighlighter); }());
以上内容是针对AngualrJS中的Directive制作一个菜单的相关知识,希望对大家有所帮助。
AngularJs Directive Pass value/object/function to Scope
记录一下
@ 单向传递字符串的值。对于外层 scope 的值,可用 {{}} 形式。
= 与父 scope 中的属性进行双向绑定,通常用于对象,无需加 {{}}
& 传递来自父 scope 的函数
angularjs directive 的几点使用技巧
传递参数给directive
<my-dir myindex="$index" title="t1"></my-dir>
app.directive(''myDir'', function () {
return {
restrict: ''E'',
scope: {
myindex: ''='',
title: ''@''
},
template:''<div>{{myindex}}</div>'',
link: function(scope, element, attrs){
console.log(''test'', scope.myindex)
}
};})
参数绑定根据需要,提供以下几种功能:
=
is two-way binding@
simply reads the value (one-way binding)&
is used to bind functions
DOM元素动态绑定CSS
可以使用ng-class命令,判断逻辑条件来动态的绑定css class给tag,基础语法为:
option 1:
function ctr($scope){
$scope.test =“classname”;
}
<div class=”{{test}}”></div>
option 2:
function Ctr($scope) {
$scope.isActive = true;
}
<div ng-></div>
option 3:
function Ctr($scope) {
}
<div ng-class = "{option.selected == ''active'' ? ''active'' : ''inactive''}"></div>
也可以用angular.element (jqLite)来实现此功能:
var ele = document.getElementById(scope.subPhaseId);
angular.element(ele).addClass(''active'');
angular.element接受String参数或DOM元素。也可直接用.css("k:v")绑定css style。
AngularJs directive-controller实例
1.代码
<body ng-app="myApp"> <my-site value="http://www.tianma3798.cn/" text="爱短句">爱短句1</my-site> <div my-sitevalue="http://www.tianma3798.cn/" text="爱短句">爱短句2</div> </body>
var app = angular.module('myApp',[]); app.directive('mySite',function () { return { restrict: 'EA',transclude: true,controller: function ($scope,$element,$attrs,$transclude) { $transclude(function (clone) { var a = angular.element('<a>'); a.attr('href',$attrs.value); a.text(clone.text()); $element.append(a); }); } } });
我们今天的关于angularjs – 量角器无法使用directConnect运行和安卓量角器的分享已经告一段落,感谢您的关注,如果您想了解更多关于AngualrJS中的Directive制作一个菜单_AngularJS、AngularJs Directive Pass value/object/function to Scope、angularjs directive 的几点使用技巧、AngularJs directive-controller实例的相关信息,请在本站查询。
本文标签: