angularjs - Angular JS adding a service to controller is not working -


i had this:

.controller('dashboardctrl', function($scope, $timeout, $location, bionicoservice, bionicosamples, $state, $locale){ 

and worked fine, call services example bionicosamples without problem had add module i18n , requires this

.controller('dashboardctrl', ['jlgi18nservice', function( i18nservice){ 

so when added code, services stoped working, , have no idea why, i'm king of new in angular , there conceptual stuff don't understand yet, instance don't understand difference betweem using "['module', function()" "function('module')"

my code after trying add module lilke this:

.controller('dashboardctrl', ['jlgi18nservice', function($scope, $timeout, $location, bionicoservice, bionicosamples, $state, $locale, i18nservice){ 

i've tried this, not working too

.controller('dashboardctrl', ['jlgi18nservice', '$scope', '$timeout', '$location', 'bionicoservice',  '$state', '$locale', function($scope, $timeout, $location, bionicoservice, bionicosamples, $state, $locale, i18nservice){ 

the error i'm getting services undefined, if try call bionicosamples.function, says ""function"" not function. know problem in way i'm importing services , modules i18n module, because before working fine

thanks!

from angular docs when using 'inline array annotation' declare controller

when using type of annotation, take care keep annotation array in sync parameters in function declaration.

the order you're injecting services wrong , have more inputs function injected services. should this:

.controller('dashboardctrl', [     '$scope',     '$timeout',     '$location',     'bionicoservice',      'bionicosamples', // missing in yours     '$state',     '$locale',     'jlgi18nservice',     function($scope, $timeout, $location, bionicoservice, bionicosamples, $state, $locale, i18nservice){ 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -