如何解析AnguarJS $ injector:modulerr(内部详细信息) [英] How to resolve AnguarJS $injector:modulerr (details inside)

查看:69
本文介绍了如何解析AnguarJS $ injector:modulerr(内部详细信息)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为网络应用程序使用自定义指令时遇到了麻烦。当我在Chrome中启动JS控制台时,出现此无法实例化模块w2l-direc的原因是:
{1}
。我在模块中编写的代码似乎有问题。

I've been having trouble using custom directives for my web app. When I pull up the JS console in Chrome, I get this Failed to instantiate module w2l-direc due to: {1}. It seems that there's something wrong with the code I wrote in my module. I'm relatively new to angular so any feed back in regards to the following code would be appreciated

(function() {
var app = angular.module('w2l-directives', ['ui.bootstrap', 'ngRoute']);
app.directive('gamesCol',['$http', function($http){
        return {
            restrict: 'E',
            templateUrl: 'games-col.html',
            controller: function(){
                this.games = $http.get('/js/games.json').success(function(data) {
                    this.games = data;
                });

                this.isSet = function(checkGame){
                    return this.game === checkGame;
                };

                this.setGame = function(activeGame){
                    this.game = activeGame;
                };
            },
            controllerAs:'game'
        };
    }]);

    app.directive('testimonyCol', function(){
        return {
            restrict: 'E',
            templateUrl: 'testimonies-col.html',
            controller: function(){
                this.testimonials = $http.get('/js/testimonies.json').successs(function(data) {
                    this.testimonials = data;
                }); 
                this.current = 0
                this.currentTestimony = testimonies[current];

                this.setTestimony = function(checked){
                    if (checked !== this.currentTestimony) {
                    this.current = checked || 0;
                    }
                };
            },
            controllerAs:'testimony'
        };
    });
})();`


推荐答案

您的错误消息对我来说很奇怪,它应该包含一个代替{1}的原因。

Your error message looks weird to me, it should have included a reason in stead of {1}.

无论如何,想到的是角度找不到您的模块依赖性。
您可以检查页面上是否包含ui.route的脚本文件吗?

Anyway, what comes to mind, is that angular can't find your module dependencies. Can you check that ui.route's script file is included on the page?

ui.bootstrap不在角度发行版中。您可以在这里找到它: http://angular-ui.github.io/bootstrap/ 。 (或者,如果您不使用它,只需删除它)

ui.bootstrap is not part of the angular distro. You can find it here: http://angular-ui.github.io/bootstrap/. (Or simply remove the dependency, if you are not using it)

这篇关于如何解析AnguarJS $ injector:modulerr(内部详细信息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆