Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 错误:$injector:moduler模块错误!安格拉斯_Javascript_Angularjs - Fatal编程技术网

Javascript 错误:$injector:moduler模块错误!安格拉斯

Javascript 错误:$injector:moduler模块错误!安格拉斯,javascript,angularjs,Javascript,Angularjs,我遇到了一个似乎无法解决的问题,我希望有人能帮我解决 我不断地发现这个错误: Failed to instantiate module musicApp due to: {1} 这是我正在使用的函数: 'use strict'; var angular = angular .module('angular', ['ngResource', 'ngRoute']) .config (function ($RouteProvider){ $RouteProvider

我遇到了一个似乎无法解决的问题,我希望有人能帮我解决

我不断地发现这个错误:

Failed to instantiate module musicApp due to:
{1}
这是我正在使用的函数:

'use strict';

var angular = angular

    .module('angular', ['ngResource', 'ngRoute'])
    .config (function ($RouteProvider){

    $RouteProvider

        .when ('/', {
        templateULR: '/templates/list-artists.html'
    })
        .when ('/add-artist', {
            templateUrl: '/add-artist.html'
    })
        .when ('/artist-details/:id', {
            templateUrl: 'artist-details.html'
    })
        .otherwise ({redirectTo: '/'});
})
    .constant ('author', 'Sekret Doge'
这就是我调用此函数的地方:

'use strict';

angular.controller('ListArtistsController',
    function ListArtistsController($scope, artistData) {

        $scope.artists = artistData.getAllArtists();

    });
'use strict';

angular.factory('artistData', function ($resource) {

        var resource = $resource('/data/artist/:id', {id: '@id'});

    return {
        getArtist: function (id) {
            return resource.get ({id: id});
        },

        saveArtist: function (artist) {

            artist.id = 999;
            resource.save (artist);
        },

        getAllArtists: function() {

            return resource.query();

        }
    }
});
这是我的html文件,它应该显示我需要的信息:

<div class="jumbotron" ng-controller="ListArtistsController">
    <div class="row">
        <div ng-repeat="artist in artists">
            <div class="col-md-4" text-center>
                <h2> <a href="#artist-details/{{ artist.id }}"> {{ artist.name }}</a></h2>
            </div>
        </div>
    </div>
</div>
页面控制器:

'use strict';

angular.controller('PageController',
    function PageController($scope) {

        $scope.author = "Sekret Doge";
        $scope.date = {
            year: 2014,
            month: 4,
            day: 4
        }

    }
);
应用程序:


谢谢你的帮助

看起来您没有加载ngRoute javascript。它在一个单独的文件中


您的.js中包含的HTML所需脚本标记中的以下库

lib/ui-bootstrap-tpls-0.9.0.min.js
在app.js的顶部添加ui.bootstrap

var angular = angular

.module('angular', ['ngResource', 'ngRoute', 'ui.bootstrap'])

它说“由于:{1}而无法实例化模块musicApp”。我添加了ngRoute,但它仍然说:/另外,ngResource是从一个单独的文件加载的。我是否缺少一个我需要添加到这篇文章中查看的文件?我不知道缺少css文件是否会导致这样的问题。我想不出还有其他人。哦,我不确定什么时候确实需要它,但您也可以尝试添加引导模板文件。ui-bootstrap-tpls.jsI没有这样的文件,我只有bootstrap.js和bootstrap.min.js你的getAllArtists()是什么;函数看起来怎么样?我已经把代码放在帖子里了,我没什么主意了。你的PageController.js和app.js文件是什么样子的?我想我们在同一个页面上,我已经在post中添加了代码。在引用你的PageController的地方,HTML是什么样子的?
lib/ui-bootstrap-tpls-0.9.0.min.js
var angular = angular

.module('angular', ['ngResource', 'ngRoute', 'ui.bootstrap'])