小编use*_*945的帖子

在beforeEach中错误Karma'undefined'范围变量

这是我的2个文件和错误.我正在运行Karma,这是我的karma.conf.js:https://gist.github.com/devanp92/a87c0bcc2bf5b8e17f64 .运行'karma start'后我得到了这个错误.这是一个非常简单的测试文件(或者我假设),我仍然会收到这些错误.

Main.js - 这是一个控制器

angular.module('SSLApp').controller('MainCtrl',  
  function($scope, $rootScope) {
    $scope.thing = 1;
});
Run Code Online (Sandbox Code Playgroud)

MainSpec.js - 这是我的测试文件

describe('MainCtrl', function() {
var controller, scope;

beforeEach(angular.module('SSLApp'));

beforeEach(inject(function($controller, $rootScope) {
    scope = $rootScope.$new();
    controller = $controller('MainCtrl', {
        $scope: scope
    });
}));

it('should have scope to be defined', function(scope) {
    expect(scope).toBeDefined();
});

});
Run Code Online (Sandbox Code Playgroud)

错误!看起来它在var MainCtrl = $ controller中被称为undefined ...

TypeError: 'undefined' is not a function (evaluating 'queueableFn.fn.call(self.userContext)')
        at /Users/BLAH/Documents/node_modules/karma-jasmine/lib/adapter.js:184
        at `http://localhost:9876/karma.js:185`
        at `http://localhost:9876/context.html:53`
    Error: [ng:areq] Argument 'MainCtrl' is not a function, got …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs karma-runner

9
推荐指数
1
解决办法
7550
查看次数

ng-map以HTML格式显示部分地图

我在Angular.js中使用ng-map由于某些原因,我的地图图片在整个地图的90%处显示为灰色,如下所示:

我的HTML非常简单:

<div id="map">
<map></map>
</div>
Run Code Online (Sandbox Code Playgroud)

我甚至试图像这样添加CSS:

<style>
    #map{
     width: 100%;
     height: 100%;
     margin: 0;
     padding: 0;
   }
</style>
Run Code Online (Sandbox Code Playgroud)

这是我的控制器:

$scope.$on('mapInitialized', function(event, map) {
  $scope.map.setCenter(new google.maps.LatLng($scope.location.latitude, $scope.location.longitude));
  $scope.setZoom(4);
}
Run Code Online (Sandbox Code Playgroud)

我添加了使用ngMap的脚本.如果可能导致问题,我也删除了任何AdBlock.

编辑:google.maps.event.trigger(map,'resize'); 作品

html javascript css google-maps angularjs

5
推荐指数
1
解决办法
4771
查看次数

标签 统计

angularjs ×2

javascript ×2

css ×1

google-maps ×1

html ×1

karma-runner ×1