Angularjs:[$ injector:modulerr]错误

时间:2014-10-28 02:55:35

标签: angularjs angular-routing

我不明白我的错误是什么。当我加载根URL时,它会显示Uncaught Error: [$injector:modulerr],而且“/ ssh”也不起作用。我使用的是1.3。这是我的代码:

<!DOCTYPE html>
<html ng-app="hiren">
<head lang="en">
    <meta charset="UTF-8">
    <base href="/" />

</head>
<body>
        <div class="col-sm-1" ng-view>

        </div>
    </div>
    <script src="lib/angular/angular.min.js"></script>
    <script src="lib/angular-route/angular-route.min.js"></script>
    <script src="src/hiren.js"></script>
</body>
</html>

hiren.js:

angular.module('hiren', ['ngRoute']).
    config( function($routeProvider, $locationProvider){
        $routeProvider
            .when('/ssh', {
                templateUrl: 'views/ssh.html',
                controller: 'ssh'

            });
        $locationProvider.html5Mode(true);
    }).
    controller('ssh', function($scope){
        $scope.xox = "example";
    });

1 个答案:

答案 0 :(得分:0)

您必须将角度代码包装在脚本标记中并将其放在html标记

<script>
angular.module('hiren', ['ngRoute']).
    config( function($routeProvider, $locationProvider){
        $routeProvider
            .when('/ssh', {
                templateUrl: 'views/ssh.html',
                controller: 'ssh'

            });
        $locationProvider.html5Mode(true);
    }).
    controller('ssh', function($scope){
        $scope.xox = "example";
    });

<script>