Hi Ku,
Here is a sample controller, utilizing an confservice.
function SampleController(configService) {
var vm = this;
Object.assign(vm,configService); //extend the controller with the
properties of the configservice
// BTW if you have to support old browsers you might use angular.extend
instead of Object.assign
// code ....
}
Do yourself a favor and stop using $scope. Read through the styleguide
<https://github.com/johnpapa/angular-styleguide>, and the component docs
<https://docs.angularjs.org/guide/component>
using $rootScope the way you do it, is the same as using globals. To know
why that is bad, google for "why is global scope bad".
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.