繁体   English   中英

角度未知提供程序错误

[英]Angular unknown provider error

我在运行grunt服务时遇到角度和自耕农的问题,这会缩小并输出我的角度应用程序到我的dist目录进行生产。 在我的本地主机上运行我的应用程序时,一切似乎都运行良好,但在进行构建之后发生了一些事情,目前我还不清楚。 任何帮助将不胜感激。

这是我向我的项目引入的导致问题的控制器:

var myPlayer

angular.module('myapp')
.controller('ShowCaseTabCtrl', function ($scope) {
    $scope.tabs = [
        {
            title:"Video",
            content:'templates/showcased-video.html',
        },
        {
            title:"Gallery",
            content:'templates/showcased-gallery.html',
        }
    ];
    // here I am firing this method on ng-include onload to ensure video js
    // is being properly instantiated
    $scope.initVideo = function() {
        videojs('showcase-video', {
            'controls': true,
            'autoplay': false,
            'preload': 'auto',
            'poster': 'images/posters/poster.jpg'
        }, function(){
            myPlayer = this;
            myPlayer.dimensions(900, 600);
            myPlayer.poster('images/posters/poster.jpg');
            myPlayer.src([
                { type: 'video/mp4', src: 'video/myvideo.mp4' },
                { type: 'video/ogg', src: 'video/myvideo.ogv' }
            ]);
        });

    }
});

这是我对上面控制器的看法:

<section ng-controller="ShowCaseTabCtrl">
<div class="mod-wrap full-bleed">
    <tabset>
        <tab ng-repeat="tab in tabs" heading="{{tab.title}}" content="{{tab.content}}" active="tab.active">
            <ng-include src="tab.content" onload="initVideo()"></ng-include>
        </tab>
    </tabset>
</div>

从yo-angular生成器运行grunt服务后我遇到错误:

Error: [$injector:unpr] Unknown provider: aProvider <- a

原因可能是你的js文件的缩小。

在声明控制器,服务和过滤器时尝试使用数组表示法。

例如

controller('ShowCaseTabCtrl', ['$scope', function ($scope) {
   // Your code here
}]);

该参考文献是Angular Phonecat教程的第5步

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM