Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.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:modulerr]未能实例化模块启动器,原因是:[$injector:nomod]模块“启动器”不可用_Javascript_Angularjs_Ionic Framework - Fatal编程技术网

Javascript 我的控制台中出现错误-[$injector:modulerr]未能实例化模块启动器,原因是:[$injector:nomod]模块“启动器”不可用

Javascript 我的控制台中出现错误-[$injector:modulerr]未能实例化模块启动器,原因是:[$injector:nomod]模块“启动器”不可用,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,[$injector:modulerr]未能实例化模块启动器,原因是: [$injector:nomod]模块“starter”不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数 当我正在为我的Ionic应用程序开发一个新功能时,我开始在我的控制台上发现这个讨厌的bug。我已经检查了我的模块,移动了一些脚本标签,但我仍然无法理解这一点。我见过其他人用这个错误把ng应用程序放在头上,我这样做了,但它不起作用。当我开始出现这个错误时,我没有碰过ng应用程序或ap

[$injector:modulerr]未能实例化模块启动器,原因是: [$injector:nomod]模块“starter”不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数

当我正在为我的Ionic应用程序开发一个新功能时,我开始在我的控制台上发现这个讨厌的bug。我已经检查了我的模块,移动了一些脚本标签,但我仍然无法理解这一点。我见过其他人用这个错误把ng应用程序放在头上,我这样做了,但它不起作用。当我开始出现这个错误时,我没有碰过ng应用程序或app.js顶部的angular.module。有人能帮我指出正确的方向吗

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
     <meta http-equiv="Content-Security-Policy" content="script-src 'self' https://maps.googleapis.com/ https://maps.gstatic.com/ https://mts0.googleapis.com/ 'unsafe-inline' 'unsafe-eval'"></meta>

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->
<script src="https://maps.googleapis.com/maps/api/js"></script>
    <!-- ionic/angularjs js -->
    <script src="js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="js/ng-cordova.min.js"></script>
      <script src="js/cordova.js"></script>


    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="css/style.css"></script>
      <script src="scss/ionic.app.scss"></script>
  </head>
  <body ng-app="starter">
    <!--
      The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable">
      <ion-nav-back-button>
      </ion-nav-back-button>
    </ion-nav-bar>

    <ion-nav-view></ion-nav-view>

  </body>
</html>

我相信你可能已经弄明白了。但只是为了以防万一而发帖对其他人有帮助。当我开始爱奥尼亚时,我就有了这个问题。你拆除工厂是关键。您用分号终止了配置,但随后将工厂链接到它后面。在.run之后还有分号,因此应该删除该分号。此外,如果你像以前一样连锁他们,每个工厂都必须以一个新的名称终止。所以我只是去掉了分号,加上了,效果很好。您不需要在.run之后使用$http.get访问example.com。你已经和我很亲近了。我把重做代码贴在下面

angular.module('starter', ['ionic', 'starter.controllers', 'ngCordova'])
.run(function($ionicPlatform, GoogleMaps) {
    $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);

        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleDefault();
        }
        GoogleMaps.init();
    });
}).config(function($stateProvider, $urlRouterProvider) {

// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider

    // setup an abstract state for the tabs directive

    .state('tab', {
        url: '/tab',
        abstract: true,
        templateUrl: 'templates/tabs.html'
    })
    .state('tab.home', {
        url: '/home',
        views: {
            'tab-home': {
                templateUrl: 'templates/tab-home.html',
                controller: 'DashCtrl'
            }
        }
    })

    .state('tab.exteriorpainting', {
        url: "/exteriorpainting",
        views: {
            'tab-home': {
                templateUrl: "services/exteriorPainting.html"
            }
        }
    })

    .state('tab.map', {
        url: "/map",
        views: {
            'tab-home': {
                controller: 'MapCtrl',
                templateUrl: 'templates/map.html'
            }
        }
    })

    .state('tab.login', {
        url: '/login',
        views: {
            'tab-login': {
                templateUrl: 'templates/tab-login.html',
                controller: 'DashCtrl'
            }
        }
    })

    .state('tab.signup', {
        url: '/signup',
        views: {
            'tab-signup': {
                templateUrl: 'templates/tab-signup.html',
                controller: 'AccountCtrl'
            }
        }
    });
$urlRouterProvider.otherwise('tab/home');}).factory('Markers', function($http) {

var markers = [];

return {
    getMarkers: function(){
        return $http.get("http://example.com/markers.php").then(function(response){
                markers = response;
                return markers;
            },
            getMarker: function(id){

        }
    }
}}).factory('GoogleMaps', function($cordovaGeolocation, Markers){

    var apiKey = false;
    var map = null;

    function initMap(){

        var options = {timeout: 10000, enableHighAccuracy: true};

        $cordovaGeolocation.getCurrentPosition(options).then(function(position){

            var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

            var mapOptions = {
                center: latLng,
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            map = new google.maps.Map(document.getElementById("map"), mapOptions);

            //Wait until the map is loaded
            google.maps.event.addListenerOnce(map, 'idle', function(){

                //Load the markers
                loadMarkers();

            });

        }, function(error){
            console.log("Could not get location");

            //Load the markers
            loadMarkers();
        });

    }

    function loadMarkers(){

        //Get all of the markers from our Markers factory
        Markers.getMarkers().then(function(markers){

            console.log("Markers: ", markers);

            var records = markers.data.result;

            for (var i = 0; i < records.length; i++) {

                var record = records[i];
                var markerPos = new google.maps.LatLng(record.lat, record.lng);

                // Add the markerto the map
                var marker = new google.maps.Marker({
                    map: map,
                    animation: google.maps.Animation.DROP,
                    position: markerPos
                });

                var infoWindowContent = "<h4>" + record.name + "</h4>";

                addInfoWindow(marker, infoWindowContent, record);

            }

        });

    }

    function addInfoWindow(marker, message, record) {

        var infoWindow = new google.maps.InfoWindow({
            content: message
        });

        google.maps.event.addListener(marker, 'click', function () {
            infoWindow.open(map, marker);
        });

    }

    return {
        init: function(){
            initMap();
        }
    }

})

我删除了app.js中的工厂,我的应用程序似乎运行得很好。那个工厂到底是怎么给我这个错误的,因为我的应用程序仍然需要它?你能创建JSFIDLE吗?
angular.module('starter.controllers', ['ionic', 'ngCordova'])

.controller('DashCtrl', function($scope) {})

.controller('MapCtrl', function($scope, $state, $cordovaGeolocation) {

});
angular.module('starter', ['ionic', 'starter.controllers', 'ngCordova'])
.run(function($ionicPlatform, GoogleMaps) {
    $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);

        }
        if (window.StatusBar) {
            // org.apache.cordova.statusbar required
            StatusBar.styleDefault();
        }
        GoogleMaps.init();
    });
}).config(function($stateProvider, $urlRouterProvider) {

// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider

    // setup an abstract state for the tabs directive

    .state('tab', {
        url: '/tab',
        abstract: true,
        templateUrl: 'templates/tabs.html'
    })
    .state('tab.home', {
        url: '/home',
        views: {
            'tab-home': {
                templateUrl: 'templates/tab-home.html',
                controller: 'DashCtrl'
            }
        }
    })

    .state('tab.exteriorpainting', {
        url: "/exteriorpainting",
        views: {
            'tab-home': {
                templateUrl: "services/exteriorPainting.html"
            }
        }
    })

    .state('tab.map', {
        url: "/map",
        views: {
            'tab-home': {
                controller: 'MapCtrl',
                templateUrl: 'templates/map.html'
            }
        }
    })

    .state('tab.login', {
        url: '/login',
        views: {
            'tab-login': {
                templateUrl: 'templates/tab-login.html',
                controller: 'DashCtrl'
            }
        }
    })

    .state('tab.signup', {
        url: '/signup',
        views: {
            'tab-signup': {
                templateUrl: 'templates/tab-signup.html',
                controller: 'AccountCtrl'
            }
        }
    });
$urlRouterProvider.otherwise('tab/home');}).factory('Markers', function($http) {

var markers = [];

return {
    getMarkers: function(){
        return $http.get("http://example.com/markers.php").then(function(response){
                markers = response;
                return markers;
            },
            getMarker: function(id){

        }
    }
}}).factory('GoogleMaps', function($cordovaGeolocation, Markers){

    var apiKey = false;
    var map = null;

    function initMap(){

        var options = {timeout: 10000, enableHighAccuracy: true};

        $cordovaGeolocation.getCurrentPosition(options).then(function(position){

            var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

            var mapOptions = {
                center: latLng,
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            map = new google.maps.Map(document.getElementById("map"), mapOptions);

            //Wait until the map is loaded
            google.maps.event.addListenerOnce(map, 'idle', function(){

                //Load the markers
                loadMarkers();

            });

        }, function(error){
            console.log("Could not get location");

            //Load the markers
            loadMarkers();
        });

    }

    function loadMarkers(){

        //Get all of the markers from our Markers factory
        Markers.getMarkers().then(function(markers){

            console.log("Markers: ", markers);

            var records = markers.data.result;

            for (var i = 0; i < records.length; i++) {

                var record = records[i];
                var markerPos = new google.maps.LatLng(record.lat, record.lng);

                // Add the markerto the map
                var marker = new google.maps.Marker({
                    map: map,
                    animation: google.maps.Animation.DROP,
                    position: markerPos
                });

                var infoWindowContent = "<h4>" + record.name + "</h4>";

                addInfoWindow(marker, infoWindowContent, record);

            }

        });

    }

    function addInfoWindow(marker, message, record) {

        var infoWindow = new google.maps.InfoWindow({
            content: message
        });

        google.maps.event.addListener(marker, 'click', function () {
            infoWindow.open(map, marker);
        });

    }

    return {
        init: function(){
            initMap();
        }
    }

})