小编cir*_*rus的帖子

AngularJs单元测试隔离范围指令

我想测试以下指令"spinInput",它需要ngModel,但是我无法访问指令的范围.我得到的只是一个空洞的范围.使用Angularjs 1.3.13.

指示:

angular.module('charts.spinInput',[]).directive('spinInput', function() {
return {
    restrict: 'E',
    replace: true,
    require:'ngModel',
    scope: {
      min:"@"
    },
    controller:function($scope)
    {
        $scope.test=12;

      $scope.calcAngle=function(point)
        {
            var xDif=point.x-50;
            var yDif=point.y-50;

            return (Math.atan2(yDif, xDif) * 180 / Math.PI);

        };

},

    templateUrl: 'charts/directive/spinInput/spinInput.html',
    link:function(scope, element, attr,ngModel) {
       ...
    }

    };
});
Run Code Online (Sandbox Code Playgroud)

单元测试: 抛出以下错误:TypeError:'undefined'不是对象(评估'innerScope.min')

 describe('spinInput', function() {

 beforeEach(module('charts'));

    var $httpBackend;
    var element;
    var outerScope;
    var innerScope;




    beforeEach(inject(function($rootScope, $compile  , $injector) {
        element = angular.element('<spin-input min="12"></spin-input>');
        $httpBackend = $injector.get('$httpBackend');
        $httpBackend.whenGET('charts/directive/spinInput/spinInput.html').respond(200, '');
        outerScope = $rootScope.$new();
        $compile(element)(outerScope);

        innerScope = element.isolateScope(); …
Run Code Online (Sandbox Code Playgroud)

unit-testing jasmine angularjs angularjs-scope

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

@ font-face IE9 font-weight不起作用

我试图用css @ font-face嵌入一个字体.我想用它作为粗体字体.但是IE 9没有显示字体粗体.

CSS

@font-face {
    font-family: Dauphin;
    src: url('dauphin.woff'),
         url('dauphin.ttf'),
         url('dauphin.eot'),
         url('dauphin.svg')
     ; /* IE9 */
     font-weight: normal;
}
.p {
     font-family: Dauphin;
     font-weight: 900;
}
Run Code Online (Sandbox Code Playgroud)

css css3 font-face internet-explorer-9

0
推荐指数
1
解决办法
5404
查看次数