Angularjs inject factory modulerr - PullRequest
       3

Angularjs inject factory modulerr

0 голосов
/ 16 июня 2020

Я использую Angularjs 1.7.6 с Laravel 7.0.2

Я хочу определить фабрику для модуля «app» и использовать эту фабрику в моем модуле «personen» ( Предполагается, что фабрика содержит некоторые глобальные переменные) и отлично работает с контроллером, который я сделал для своего «приложения». Немного поискав, я сузил проблему до внедрения моего модуля, но я не могу понять это правильно, я уже несколько часов искал ответ в Google, и мне не удается его решить.

Plunkr: https://plnkr.co/edit/tT3teybi7Xr1qKQh?open=lib%2Fscript.js&deferRun=1&preview

Любая помощь приветствуется!

Мои модули и контроллер:

var app = angular.module('app',['ngMaterial','ngMessages'])
        .constant('API_URL', 'http://172.16.48.80/api/v1/')
        .config(['$mdDateLocaleProvider',function($mdDateLocaleProvider){
                $mdDateLocaleProvider.formatDate = function(date){
                        return moment(date).format("DD.MM.YYYY");
                };
                $mdDateLocaleProvider.parseDate = function (dateString) {
                        var m = moment(dateString, 'DD.MM.YYYY', true);
                        return m.isValid() ? m.toDate() : new Date(NaN);
                };
        }])
        .factory('globalVariables',function(){
                var tabs = [{title:"bla",content:"SomeContent"}];

                return{
                        tabs:tabs,
                }
        });
var personen = angular.module('personen', ['ngMaterial','ngMessages','app'])
        .constant('API_URL', 'http://172.16.48.80/api/v1/')
        .config(['$mdDateLocaleProvider',function($mdDateLocaleProvider){
                $mdDateLocaleProvider.formatDate = function(date){
                        return moment(date).format("DD.MM.YYYY");
                };
                $mdDateLocaleProvider.parseDate = function (dateString) {
                        var m = moment(dateString, 'DD.MM.YYYY', true);
                        return m.isValid() ? m.toDate() : new Date(NaN);
                };
        }]);

personen.controller('personenController',['$scope','$http','API_URL','globalVariables',function($scope,$http,API_URL,globalVariables){
//SomeStuff , getting error regardless of what is inside this controller
}]);

Файл Я пытаюсь открыть (адрес. php):

<html lang="de" ng-app="personen">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,schrint-to-fit=no">
        <link rel="stylesheet"
            href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
            integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
            crossorigin="anonymous">
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.12/angular-material.min.css">
        <link rel="stylesheet" href="assets.css">
        <link rel="stylesheet" href="css/adressen.css">
        <title>Title</title>
    </head>
    <body>
        <div class="container-fluid" ng-controller="personenController">
        <!-- A bunch of tables to display data and other stuff to work with that data -->
        </div>
        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
            integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
            crossorigin="anonymous"></script>
        <script
            src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
            integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
            crossorigin="anonymous"></script>
        <script
            src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
            integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
            crossorigin="anonymous"></script>

        <!-- Load Javascript Libraries (AngularJS, JQuery, Bootstrap) -->
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.6/angular.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.6/angular-animate.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.6/angular-aria.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.6/angular-messages.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.12/angular-material.min.js"></script>
        <script src="http://code.angularjs.org/1.7.6/i18n/angular-locale_de-de.js"></script>
        <script src="https://momentjs.com/downloads/moment.min.js"></script>
        <!-- AngularJS Application Scripts -->
        <script src="app/app.js"></script>
        <script src="app/controllers/personen.js"></script>
        <script src="js/assets.js"></script>
    </body>
</html>

Сообщение об ошибке: Ошибка: [$ injector: modulerr] http://errors.angularjs.org/1.7.6/ $ injector / modulerr? p0 = pers…% 2Fcode. jquery .com% 2F jquery -3.2.1.slim.min.js% 3A2% 3A30517% 0A

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...