Search Posts

Category: service

getting TypeError : XYZ is not a function in Angular

I went through few questions and trying to solve this issue, but not getting success yet. I am getting this error : TypeError: appService.load_All_EV is not a function. I used same way to call data from service in other controller and its working fine. This is my service. app.factory(“appService”, function($http) { return { GetApp: function() { return $http({ method: ‘GET’, url: ”, headers: { ‘Content-Type’: ‘application/json’ } }).then(function(response) { return; }); }, load_All_EV: function() […]

Value set from one controller into service to be used on another controller returns no value on page refresh using angular js(new to angular)

I have a HTML code <div id=”{{item.codeName}}”> <a class=”search-results” href=”” ui-sref=”app.location” ng-click=”vm.setValue(item._id)”>{{item.codeName}} </a><br><br> </div> on ng-click from the controller i’m invoking a function vm.setValue by passing id to controller1 where i am passing id value to the service to set. In Controller1 vm.setValue = function(Id){ service.setId(Id); } My Service angular.module(‘myApp’, []) .service(‘setProperties’, function () { var _Id = null; function getId(){ return _Id; } function setId(Id){ _Id = Id; } }); I was successful setting […]

difference between angular services and their nomenclature to create custom services and use as a function arguments [duplicate]

This question already has an answer here: What is the $$ (double dollar sign) used for in angular? 2 answers what is difference between using $ sign in prefix of any service and without $ sign ? here in above code how nomenclature is differentiated ? function topicCtrl($scope, topicService, $uibModal, $sce ){} Source: AngularJS

Not able to print data using Angular js 2

I’m not sure where I went wrong, created aMean Stack app both server side and client. Server side works fine I’m able post, get and delete data from Table, but not able to display get data in component.html file. I have shared my component, services and html files, please find what’s the error. If you need any another file I can share. This is ideas.component.html <div class=”container”> <div *ngFor=”let idea of ideas”> <div class=”col-md-3″> {{ideas.Name}} […]

Unknown provider: serviceProvider -> service -> myDirective

A recent change to the software I am working on left me with the following error: “exception: Error: [$injector:unpr] Unknown provider: tableNavigationProvider <- tableNavigation <- ajSearchSelectDirective$injector/unpr?p0=tableNavigationProvider%20%3C-%20tableNavigation%20%3C-%20ajSearchSelectDirective” Now I have looked at multiple stack overflow boards but none of them is any help. How do I find the problem with this error? Sites that I already looked at:$injector/unpr angular js unknown provider After looking at all these and properly testing (to recreate this […]

FirebaseUI authState subscribe: returning values

I am having some trouble understanding how to return and use the data returned with angular and FirebasUI ( For now, I am returning data from the authstate with ngOnInit(): void { this.afAuth.authState.subscribe(d => console.log(d)); } and this returns in the console {currentUser: Hk, credential: null, redirectUrl: undefined} my question: how do I access currentUser in order to use *ngIf to apply conditional formatting of my pages. Thanks in advance Source: AngularJS

AngularJS, Services and promises, best practice 2018

Basically, I am building a massive app, using SailsJS and AngularJS. I’m ratter new to both of them. I’ve started this app with few Controllers, but seeing how it’s getting messy, I started to move the interaction with my Backend API into Services (mostly the $http functions). I quickly noticed that the “asynchonousity” of it messed most of my logic. I never used the $q of Angular, and $http kind of do it by itself […]

Angularjs service to toggle own model object boolean using $interval

With the help of user3696882 I managed to set up a service: app.service(‘metro’, function() { this.flagValue = {value: false}; this.setFlagValue = function(flagValue){ this.flagValue.value = flagValue; }; this.getFlagValue = function(){ return this.flagValue; }; }); that forms the model for a boolean that is being toggled true/false every second by one of my controllers: function GlobalCtrl( $scope , $interval , metro ) { var th = this; $interval(function () { th.pulse = !th.pulse; metro.setFlagValue( th.pulse ); }, […]

angularjs referencing service getter from controller

My Angularjs project needs a service to supply a toggling boolean to other services. Ideally, there could be an $interval() loop inside the service (but I think it would not work like that). I created a service with s simple setter and getter: app.service(‘metro’, function() { this.setFlagValue = function(flagValue){ this.flagValue = flagValue; } this.getFlagValue = function(){ return this.flagValue; } }); A global controller toggles a boolean property in an $interval() loop function GlobalCtrl( $scope , […]

AngularJS – Service with promise for common warning message

This is the first time I attempt to implement a service with promise and, so far, without success… I’m implementing a SPA using AngularJS which can display an unlimited number of tabs at any given moment. There are tens of different tab types, each managed by its own controller. At any given moment, any number of tabs can be open, including more than one instance of the same tab type (e.g. a tab to edit […]

Next Page »