447 questions
1
vote
0
answers
35
views
AngularJs - How to update Internal data within a Factory?
I have a factory in my app which takes environment uri data as input parameter and returns a $resource object as below. The coreService is a singleton object used in many other controllers of UI. ...
-1
votes
1
answer
50
views
How can I implement caching in angularJs factory?
How can I implement caching in the angularJs factory without using cacheService?
1
vote
0
answers
74
views
AngularJS - How to construct the url of endpoint with 2 parameters
I am relatively new to AngularJS and I was working on making the following within the Service with factory.
I have the following call within the Service:
factory.getUsers = function () {
var ...
0
votes
1
answer
977
views
Migrating an AngularJS factory to TypeScript
I am in the process of preparing to migrate an AngularJS app to Angular. I am currently looking at converting the JS code to TS. I haven't had any issues with components and services but factories. I ...
0
votes
1
answer
111
views
How to use module function inside another factory in angularjs
I have configurations.js file which having
var configurationModule = angular.module('configuration', ['restangular', 'notification']);
configurationModule.factory('clientConfigSvc', function (...
0
votes
1
answer
83
views
Propagating Scope Events from a Factory
Neither $rootScope.$broadcast nor $rootScope.$emit is working from my factory
I have $rootScope injected into the factory. The factory returns this function:
alertHook: function() {
$rootScope.$...
0
votes
0
answers
83
views
AngularJS advice on converting Factory to Provider?
I need to inject content from a Factory into a Config but I know this isn't possible and is only possible if I use a provider instead, so please can anyone advise how to convert my factory into a ...
6
votes
1
answer
554
views
AngularJS injecting third party module ngIdle
I have a controller as shown below.
(function () {
"use strict";
var app = angular.module('Demo')
.controller('MainController', ['$rootScope', '$scope', '$location', 'curUser',MainController]);
...
0
votes
1
answer
93
views
AngularJS Error, "Cannot read property of unknown"
I am trying to create a factory to retrieve weather data for a simple web page I am creating but, I am getting stuck when trying to call the function in the factory. I have fallowed Dan Wahlin's ...
1
vote
2
answers
485
views
Syntax error in openweathermap API request
I'm getting the following syntax error in the console while trying to get data from 'openweathermap'
Uncaught SyntaxError: Unexpected token :
Here is the JS file :
var app = angular.module('App', [...
0
votes
1
answer
278
views
Not able to call factory method after including factory function with $provide.factory in angular.js
app.config(['$controllerProvider','$compileProvider', '$filterProvider', '$provide',function($controllerProvider,
$compileProvider, $filterProvider, $provide) {
app.register = {
...
0
votes
2
answers
40
views
AngularJS - Why does my factory not update the DOM?
In my html I have:
<body ng-app='myApp'>
<h1 ng-controller='controller'>
{{YesOrNo}}
</h1>
<div ng-controller='controller'>
<span>{{YesOrNo}}&...
0
votes
2
answers
66
views
Error: "fourSquareService.getVenues is not a function"
AngularJs - how to use factory with form input as part of URL to fetch?
First question here. I am studying angular and was trying to use separated files for my services and also using a user input on ...
0
votes
2
answers
62
views
AngularJS - Factory from Controller - not getting value from $http.get
I have a newbie question here.
I am coding a factory in angularJS. With it I want to have a list of users, and also a method to fill it.
So this is my code ...
The factory
app.factory("...
0
votes
0
answers
109
views
AngularJS .then() function is not returning data after getting successful response [duplicate]
I am working on AngularJS 1.6.9 JSONP . My api endpoint gives projectInstance.jsonpCallback function as a response. Inside factory method i had created same callback function and i got the response. ...
0
votes
0
answers
157
views
AngularJs ~1.6 pass parameter using ng-pattern to factory
Is it possible to pass a parameter from ng-pattern(html input) to AngularJs factory?
At the moment, I have a custom factory validateFormFieldFactory. And the custom factory/service is going to be ...
0
votes
1
answer
48
views
angularjs make json to array and use in a factory
This is the factory I use right now, I get 2 json objects and try to do a array of them then I cant use it in the textreplacer.
app.factory('myFactory', function ($http) {
var service = {}
var ...
0
votes
1
answer
103
views
AngularJS setting directive scope variables from a service
OK so I am trying to make a simple chat widget directive and I want it to be dynamically created wherever I want it on my app ie I do not want a hard coded solution. So I want the directive to be ...
-1
votes
2
answers
98
views
Can't return results from async AngularJS factory to controller
I've read a dozen blog posts and StackOverflow answers but my factory won't return its results to the controller. In the controller, I first make an object to send data to the factory, then call the ...
1
vote
1
answer
1k
views
Angular js - How to call directive after creating the directive dynamically?
So what I'm doing is adding a directive as an attribute to an element via a Factory. And I have a separate directive file that manipulates the DOM based on some event triggered on that element, the ...
0
votes
1
answer
263
views
sharing $scope between controller and factory in AngularJS
I have a variable 'file' that is being passed to a directive which i am using in the same controller. Now i want to use that same 'file' in the factory that i am creating but i'm not sure if there is ...
-1
votes
1
answer
178
views
Get data from Parse.com using AngularJS factory
I'm developing an e-commerce web app using AngularJS (v1.6.7) and Parse Server (v2.3.3).
I created Category and Product class in Parse Server. I'm trying to fetch in a certain amount of products per ...
0
votes
1
answer
1k
views
Why is rootScope.on called multiple times in my application?
In my AngularJS application, I have a controller-A and a factory. I am using the following code in factory to call the function in controller-A. In the initial call, the function in controller A's ...
0
votes
2
answers
410
views
Run a function before running a controller
I have defined a factory auth as follows:
app.factory('auth', [function () {
var auth = {};
auth.getUser = function () {
... ...
// get user from cookie, cache, history, etc.
...
0
votes
1
answer
148
views
How pass values between controllers with a factory?
I'm trying to pass data between (I think) two child controllers.
Trying to do this with a factory.
testFactory.js
app= angular.module('testApp');
app.factory('values', [...
0
votes
4
answers
122
views
Move model out of service
I am a bit new to angularjs. I have a service that works fine. however I would like to move the model (the patient model) out of the service and put it in a separtate javascript file. not quite sure ...
0
votes
1
answer
77
views
Pass data from factory to Angular Controller
I have an existing Angular Factory and I'm having some trouble inserting some new code that needs to pass the results of a $resource get to my Angular Controller. I'm trying to do this in the "...
0
votes
0
answers
753
views
HTTP GET Calling Multiple times in AngularJS Factory
I have created the angular Factory to get the results from the PHP and calling only one time but when I see in the Network its calling multiple times as shown below and its taking lot of time to get ...
0
votes
1
answer
2k
views
How to define multiple functions and call one function inside other function in Angular JS Factory
Can Anyone help me how to create multiple function in Angular JS Factory, And I want to access the returned value from one function and process something in another function , I have tried below but ...
0
votes
2
answers
182
views
Unable to fetch json data using angular factory service [duplicate]
I am unable to fetch my json data using angular factory service.
I seem to load the files correctly, no error on developer tools console, still the data is undefined on the request - means empty.
...
0
votes
3
answers
61
views
Re-Usable Angularjs Code
I have scope function ClickA and ClickB in my controller CtrlA, I want to re-use ClickA and ClickB with there containing scope variables "a" and "b" in almost every other controllers, I mean, I simply ...
0
votes
0
answers
37
views
Why Angularjs factory needs another factory even it's not used
It's just a short question about AngularJS dependency injection.
I have two factories, factoryA and factoryB, factoryB not using factoryA but factoryB not working if factoryA is not injected to it.
...
-1
votes
1
answer
37
views
Loading properties
So i have a file called app.properties which contains to urls in the format of
somethingurl=http://.../.../.../something.js
Note:there is actual url
But i switched to an internet less environment ...
0
votes
2
answers
60
views
Can't update vars inside Angularjs Factory
Anyone can help with this? Can't update var ABCKey. Execute setAuthenticatedAccount and console.log return correct value. After that, run getAuthenticatedAccount, and receive undefined.
angular....
1
vote
2
answers
209
views
ionic v1 storing token in service not working angularjs
I'm trying to store a token from a login service in a variable, to retrieve it later and add it to the header in order to be able to consume more services from the API. I'm able to login and get the ...
3
votes
1
answer
1k
views
How to properly reset angularjs v1 factory after certain function
I Made a factory that keeps the information in my scopes in a series of 6 pages. Now when the user completes the 6th page and pushes the object I want the factory to reset to empty arrays again.
I ...
1
vote
3
answers
860
views
Can't get response from Angular $resource
I have a factory:
.factory('CompanyRolesResource', function($resource, FdConfig) {
return $resource(FdConfig.routes.companyRoles);
})
And I have a function that use this factory:
ctrl....
0
votes
1
answer
165
views
How to inject $rootScope into Factory Function in AngularJS
I've been given some AngularJS code that has a factory function that is called from a Directive that Posts a file to Web API. I'm having trouble passing the key that is returned to my controller. ...
9
votes
1
answer
791
views
Send $http.get twice
Edit 1: Guys, I notice that I call $http.get('/posts') (for some special purpose) in my authentication factory. Sorry for the stupid question. I will delete it when the bounty is end.
I have the ...
1
vote
1
answer
405
views
AngularJS controller is not a function, got undefined (data from factory)
I'm refactoring an old AngularJS project so it's less dumb and bad, separating controllers and exporting data with a factory rather than having all the data inside of one giant controller. I can't get ...
1
vote
2
answers
68
views
Cannot get data from service after migrating to AngularJS 1.6.3
After migrating to AngularJS 1.6.3, I changed my services like below:
Here is my service:
MetronicApp.factory('MyService', ['$http', function($http) {
return {
get: function(id, success, ...
0
votes
2
answers
267
views
Defer return of factory until loop is completely finished angularjs
I'm trying to make a method that returns an array of objects after getting the objects from an API. The problem is that the return from the factory happens before all the calls are finished. I've ...
0
votes
1
answer
559
views
$http service in Factory returns undefined in AngularJS
I am new in angularJS and try to make a CRUD operation to clear my concept. I try to use angular factory but I google a lot and unable to find any solution on below concept. I just want to use my ...
0
votes
1
answer
161
views
Using $inject in a service is giving an error Error: [$http:badreq] - Angular JS
There is a register form. On submit of register form I am trying to save the data through angular service. It is giving me an error Error: [$http:badreq]
This is my register.controller.js
(...
0
votes
3
answers
380
views
Wrong value of scope in angular controller
I am new to angular 1, and I have problem with my code:
var app = angular.module("Football", []);
app.factory("competitions", ['$http', function($http) {
return $http.get("json/competitions.json")...
0
votes
1
answer
701
views
Dynamic table rendering by JSON data
I have something challenging requirement and looking for solution to render it dynamically. I would request experts to help me on below requirement.
I need to render the data as per the above format ...
2
votes
5
answers
5k
views
(AngularJS) Can't inject factory into controller
I'm trying to inject my factory into a controller. If I list the factory as one of the controller's parameters, I get this error:
Error: [$injector:unpr] Unknown provider: wordRushFacProvider <- ...
0
votes
1
answer
846
views
Rest Webservice call in AngularJS ( promise )
AngularJS : 1.4.X
Scenario 1: Works fine
Scenario 2: Throws 404 error on line xhr.send(isUndefined(post) ? null : post); in angular.js
I'm trying to add inbuilt angular cache to our existing app, ...
1
vote
2
answers
1k
views
AngularJS - Factory variable doesn't update in controller
I'm facing a new issue with AngularJS.
Infact, since I need to have a "shared" variable, readable and updatable in 2 controllers, I thought about doing that with a factory injected in both the ...
0
votes
1
answer
688
views
Angularjs : Call factory twice on same controller [duplicate]
I have the following code which is not working as expected, maybe because I am new on angular :)
I want to re-call the same factory function whenever I append a new record to my database, because ...