久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

$scopeProvider <- $scope/未知提供者

$scopeProvider lt;- $scope/ Unknown provider($scopeProvider - $scope/未知提供者)
本文介紹了$scopeProvider <- $scope/未知提供者的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

我用 jasmine(http://jasmine.github.io/2.0/) 并得到下一個(gè)錯(cuò)誤:未知提供者:$scopeProvider <- $scope我知道,在過濾器、服務(wù)、工廠等中使用范圍建立依賴關(guān)系是不正確的,但我在控制器中使用了 $scope!為什么我會(huì)收到此錯(cuò)誤?控制器看起來像

I testing my angular-application with jasmine(http://jasmine.github.io/2.0/) and getting next error: Unknown provider: $scopeProvider <- $scope I know, that it's incorrect to build dependency with scope in filters, services, factories, etc., but I use $scope in controller! Why am i getting this error? controller looks like

testModule.controller('TestCont', ['$filter', '$scope', function($filter, $scope){

        var doPrivateShit = function(){
            console.log(10);
        };

        this.lol = function(){
            doPrivateShit();
        };

        this.add = function(a, b){
            return a+b;
        };

        this.upper = function(a){
            return $filter('uppercase')(a);
        }   

        $scope.a = this.add(1,2);

        $scope.test = 10;

        $scope.search = {

        };
    }]);

和我的測(cè)試代碼:

'use strict';

describe('testModule module', function(){
    beforeEach(function(){
        module('testModule');
    });

    it('should uppercase correctly', inject(function($controller){
        var testCont = $controller('TestCont');
        expect(testCont.upper('lol')).toEqual('LOL');
        expect(testCont.upper('jumpEr')).toEqual('JUMPER');
        expect(testCont.upper('123azaza')).toEqual('123AZAZA');
        expect(testCont.upper('111')).toEqual('111');
    }));
});

推薦答案

你需要手動(dòng)傳入一個(gè) $scope 給你的控制器:

You need to manually pass in a $scope to your controller:

describe('testModule module', function() {
    beforeEach(module('testModule'));

    describe('test controller', function() {
        var scope, testCont;

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

        it('should uppercase correctly', function() {
            expect(testCont.upper('lol')).toEqual('LOL');
            expect(testCont.upper('jumpEr')).toEqual('JUMPER');
            ...
        });
    });
});

這篇關(guān)于$scopeProvider <- $scope/未知提供者的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認(rèn)為文檔“準(zhǔn)備好之前,如何讓我的 jasmine 測(cè)試裝置加載?) - IT屋-程序員軟件開發(fā)技術(shù)
What do jasmine runs and waitsFor actually do?(jasmine 運(yùn)行和等待實(shí)際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測(cè)試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對(duì)鏈?zhǔn)椒椒ㄟM(jìn)行單元測(cè)試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測(cè)試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監(jiān)視函數(shù)中的函數(shù)調(diào)用?)
主站蜘蛛池模板: 午夜久久久 | 国产精品日韩欧美一区二区三区 | 九九九国产 | 国产福利91精品一区二区三区 | 日本一卡精品视频免费 | 久久精品中文字幕 | 精品国产99 | 在线观看中文字幕一区二区 | 成人久久| 自拍 亚洲 欧美 老师 丝袜 | 国产精品一区在线 | 免费大黄视频 | 中文字幕欧美在线观看 | 九九亚洲 | 91久色 | 成人在线小视频 | 91视频在线网站 | 一区二区三区精品视频 | 日韩欧美三级在线 | 一区二区三区播放 | 蜜臀久久99精品久久久久久宅男 | 中文字幕一区二区三区不卡在线 | 日韩欧美一区二区三区 | 一级黄在线观看 | 在线播放国产视频 | 人人草人人干 | 综合久久99 | 国产精品免费观看 | 一区二区三区小视频 | 在线观看中文视频 | 男人的天堂在线视频 | 久久国产精品一区二区三区 | 欧美日韩精品一区 | 99久久精品免费看国产小宝寻花 | 久久亚洲一区二区三区四区 | 欧美一级做a爰片免费视频 国产美女特级嫩嫩嫩bbb片 | 国产精品一区久久久 | 欧美性大战久久久久久久蜜臀 | 免费视频一区二区 | 精品二区 | 国产精品黄 |