2016-04-28 49 views
0

我正在使用Angular-fullstack作爲生成器。我產生了一個叫做視頻的路線。但是當我運行grunt測試:客戶端我給我看這個錯誤 -模塊「視頻」不可用

Error: [$injector:nomod] Module 'video' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 
    http://errors.angularjs.org/1.5.3/$injector/nomod?p0=video 

測試代碼是由angular-fullstack生成的。這裏是我的測試代碼 -

'use strict'; 

describe('Component: VideoComponent', function() { 

    beforeEach(module('video')); 

    var VideoComponent, scope; 

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

    it('should ...', function() { 
    expect(1).to.equal(1); 
    }); 
}); 

這裏是我的測試我的控制器代碼 -

'use strict'; 
(function(){ 

class VideoComponent { 
    constructor() { 
    this.message = 'Hello'; 
    } 
} 

angular.module('video') 
    .component('video', { 
    templateUrl: 'app/video/video.html', 
    controller: VideoComponent 
    }); 
})(); 

誰能告訴我什麼是錯在這裏。提前致謝!!

回答

1

我在第一次使用angular-fullstack的時候遇到了同樣的問題。我認爲您必須將組件名稱更改爲'視頻',因爲您在測試中描述了視頻作爲控制器中的組件名稱。

describe('Component: video', function() { 

    beforeEach(module('video')); 
    ....... 
    ....... 
+0

它會工作,如果我更改兩個組件名稱'VideoComponent'? – recharDS

+0

我這麼認爲。我的意思是它應該工作..... – JP1248

+0

更改爲'視頻'工作。讓我檢查另一個。 – recharDS