当控制器,服务,指令放入单独的文件时,模块不可用错误

时间:2017-10-05 02:37:18

标签: angularjs dependency-injection module

我有一个有角度的应用程序,我有app.run.js和app.controllers.js

以前我使用的是一个main.js,应用程序工作正常,但现在何时 我把控制器和run.js分开了

我没有收到任何模块错误。

Error: $injector:modulerr
Module Error

我在这里做错了什么?

请查看代码的小提琴



<!DOCTYPE html>
<html lang="en">

<head>
    <title>Starfleet</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="icon" href="http://webstandards.delhivery.com/favicon.ico">
    <link rel="stylesheet" href="https://webstandards.delhivery.com/2.1.0/libs/ws/delhivery.css">
    <link rel="stylesheet" href="styles/style.css">
</head>

<body ng-app="starfleet-app" ng-controller="pageController as vm">
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.min.js"></script>
    <script src="https://webstandards.delhivery.com/2.1.0/libs/ws/delhivery.js"></script>
    <script src="scripts/app.run.js"></script>
    <script src="scripts/controllers/app.page.controller.js"></script>
 
</body>

</html>

This is my app.run.js

angular.module('starfleetApp',['dlv-ng','ngRoute']);
angular.module('starfleetApp').config(function($routeProvider) {
    debugger;
        $routeProvider
            .when('/', {
                templateUrl: './../partials/tracking.html'
            })
            .when('/create', {
                templateUrl: './../partials/createOrder.html'
            })
            .when('/singleUpload', {
                templateUrl: './../partials/singleUpload.html'
            })
            .otherwise({
                redirectTo: '/'
            });

    });
    
   
This is my app.page.controller.js

angular.module("starfleetApp").controller('pageController', function($scope, $uibModal, $log, $document, $rootScope) {


});
    

<!-- begin snippet: js hide: false console: true babel: false -->
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您是否尝试将angular.module("starfleetApp")更改为angular.module("starfleet-app")

根据你的html和JS,你使用了错误的模块名称。这可能会解决您的错误。

修改

工作代码 http://jsbin.com/komodukipe/edit?html,output