Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 《茉莉花》中的ng秀没有改变_Javascript_Angularjs_Ng Show - Fatal编程技术网

Javascript 《茉莉花》中的ng秀没有改变

Javascript 《茉莉花》中的ng秀没有改变,javascript,angularjs,ng-show,Javascript,Angularjs,Ng Show,我正在为显示旋转器的角度指令编写一些jasmine测试。我的指令如下: define([ "app", "spin" ], function( app, Spinner ){ 'use strict'; return app .directive('processing', function() { return { restrict:'E',

我正在为显示旋转器的角度指令编写一些jasmine测试。我的指令如下:

define([ "app", "spin" ], function( app, Spinner ){ 'use strict'; return app .directive('processing', function() { return { restrict:'E', transclude: false, scope: { show: '=show', message: '=message' }, templateUrl: 'directives/spin/processing.html', link: function(scope, element, attrs) { var spinner = new Spinner({ lines: 17, // The number of lines to draw length: 40, // The length of each line width: 10, // The line thickness radius: 60, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset direction: 1, // 1: clockwise, -1: counterclockwise color: '#000', // #rgb or #rrggbb or array of colors speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: true, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }).spin(); var loadingContainer = element[0].querySelectorAll('.processing-spinner-container')[0]; loadingContainer.appendChild(spinner.el); } }; }); }); 定义([ “应用程序”, “旋转” ],功能( 应用程序, 纺纱机 ){ "严格使用",; 返回应用程序 .directive('处理',函数()){ 返回{ 限制:'E', 排除:错误, 范围:{ show:'=show', 消息:'=消息' }, templateUrl:'directions/spin/processing.html', 链接:函数(范围、元素、属性){ 变量微调器=新微调器({ lines:17,//要绘制的行数 长度:40,//每行的长度 宽度:10,//线条粗细 半径:60,//内圈的半径 拐角:1,//拐角圆度(0..1) 旋转:0,//旋转偏移量 方向:1,//1:顺时针,-1:逆时针 颜色:'#000'、//#rgb或#rrggbb或颜色数组 速度:1,每秒//圈 轨迹:60,//余辉百分比 shadow:true,//是否渲染阴影 hwaccel:false,//是否使用硬件加速 className:'微调器',//要分配给微调器的CSS类 zIndex:2e9,//z索引(默认为2000000000) top:'自动',//在px中相对于父对象的top位置 左:“自动”//在px中相对于父对象的左位置 }).spin(); var loadingContainer=element[0]。querySelectorAll('.processing微调器容器')[0]; loadingContainer.appendChild(spinner.el); } }; }); }); 我的模板如下所示:

现在,当我想做一个jasmine单元测试,测试ng show时,我有这样的东西

it('should be there when ngShow is true', inject(function($rootScope, $compile) { $scope = $rootScope.$new(); $scope.show = true; var element = $compile('<processing>\</processing>')($scope); $scope.$apply(); var spinnerContainer = element[0].querySelector('.processing-spinner-container'); expect(spinnerContainer.classList.contains('ng-hide')).toBe(false); })); 它('ngShow为true时应该在那里',inject(函数($rootScope,$compile){ $scope=$rootScope.$new(); $scope.show=true; var元素=$compile('\')($scope); $scope.$apply(); var spinnerContainer=元素[0]。查询选择器('.processing spinner container'); expect(spinnerContainer.classList.contains('ng-hide')).toBe(false); }));
然而,这个测试失败了。即使我将$scope.show设置为true,它仍然有
ng hide

你查过文摘了吗$scope.digest();