Domanda

I know it's an error on my part wiring it up and I've tried several different ways with the same result, injection error. Here is a jsFiddle http://jsfiddle.net/willtx/XZ3sX/1/ the has what I'm trying to wire up ( BUT it is broken there as well, not throwing an error or anything), my apologies. I'm pretty green here. It seems straight forward but....

This is the error when it executes. If I remove the code the page starts working again. Error: [$injector:unpr] Unknown provider: $rootscopeProvider <- $rootscope <- AddressBroadcastService

AddressBroadcastService's function is to allow other controllers to kickoff/react to an address verification. Here's an example of one of the other controllers that will react to the braodcast.

<div ng-controller="AddressCheckerController">
<script type="text/ng-template" id="AddressCheck.html">
    <div class="modal-header">
        <h3 class="modal-title">Address Verification</h3>
    </div>
    <div class="modal-body">
        <p>
            Address to verify:<br />
            {{selectedRow.address}}
        </p>
        <span>Addresses found:</span>
        <ul>
            <li ng-repeat="address in modalItems">
                <a ng-click="selected.modalItem =  address">{{ address }}</a>
            </li>
        </ul>
        Selected: <b>{{ selectedAddress }}</b>
     </div>
     <div class="modal-footer">
        <button class="btn btn-primary" ng-click="ok()">OK</button>
        <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
     </div>
  </script>
</div>

I'm wide open to suggestions if I'm way off base.

È stato utile?

Soluzione

In this line you are creating a module myApp while injectcing angularStart.services

var appRoot = angular.module('myApp', ['angularStart.services']); 

In this line you are trying to create a module `angularStart.services while injecting nothing

var angularStartServices = angular.module('angularStart.services');

The second one should be:

var angularStartServices = angular.module('angularStart.services', []);

if you pass one parameter to angular.module it is a get reference to a module function if you pass two it is a module creation call

Other things I found:

  • must inject ngResource into your appRoot module
  • and in order to inject ngResource you must include a reference to the angular-resource js file
  • $rootscope should be $rootScope

I updated your fiddle w/ these chnage

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top