javascript - Angular Unknown provider -
for reason factory not being injected controller expected.
index.html
<script src="js/app.js"></script> <script src="js/tagfactory.js"></script> <script src="js/bluetoothfactory.js"></script> <script src="js/bluetoothcontroller.js"></script> app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']) tagfactory.js
angular.module('starter.services', []).factory('decodefactory', ['$q', '$window', '$rootscope', function($q, $window, $rootscope) { //.... empty now. }]) bluetoothfactory.js
angular.module('starter.services', []).factory('bluetoothfactory', ['$q', '$window', '$rootscope', function($q, $window, $rootscope) { ... }]) bluetoothcontroller.js
angular.module('starter.controllers',[]).controller('bluetoothctrl', function($scope, $ionicmodal, $timeout, bluetoothfactory, decodefactory) {...}); when running page in browser receive following error:
error: [$injector:unpr] unknown provider: decodefactoryprovider <- decodefactory <- bluetoothctrl
any appreciated.
you creating starter.services module twice, causing first 1 overwritten. either need give them 2 different module names or need use getter method, angular.module('starter.services'), second one.
Comments
Post a Comment