Tagged Questions
0
votes
2answers
45 views
Angularjs Passing array between controllers
I have been through several tutorials and posts about this topic and still can't seem to figure out what is wrong with my code. To me it seems I am having scoping issues with the data within my ...
1
vote
4answers
31 views
Factory has two methods, one is $http method with $promise - how to reference the other method from within the first one's success function?
In one of my factories I need to set a variable when data is fetched (through $http) so I can access it in my controller (the intention is to display a spinner image until the data is loaded).
...
1
vote
0answers
17 views
Bind Service 'getter' or $watch changes and update manually - AngularJS
In my AngularJS app I'm using a service to store info that's being updated by a simple polling mechanism. Then, my controllers/directives are reading from that service, so that I can have that model ...
0
votes
0answers
14 views
AngularJS + require.js + routing: how to build for scalability?
I've been researching using Google for a few days now. Going in circles, maybe someone with experience could give me a few pointers on the concepts.
Scope:
Need a scalable mobile site using ...
0
votes
2answers
30 views
Using $provide and $q
I'm building a mobile app using Ionic in conjunction with ngCordova. In the hopes of developing in the browser as much as possible I want to override the ngCordova methods to return mock responses ...
1
vote
2answers
35 views
In my service-factory I lookup up a large dataset - I want to persist it and check for its existence to avoid calling it again
My service (factory) makes an API call and assigns response data to a variable:
.factory('MedicationMatchingNamesFactory',
['$http', '$q', 'MedicationDisplayNamesFactory',
...
0
votes
0answers
22 views
Jasmine - AngularJS $https inside a service
I am newbie in Jasmine. I have angular service like below,
app.factory('helper', ['$http', function($http){
var helper = {};
helper.http = function(setting){
if(typeof ...
0
votes
1answer
13 views
Error when accessing a AngularJs service method which uses $resource
i'm new to angularjs and trying to access a service method which uses $resource to make a call to my rest api. But when i'm trying to access its giving a error. also when i try to access a method ...
0
votes
3answers
23 views
How to access an object attribute inside a service in AngularJS?
I have a service with a local variable object with events names:
myApp.service('appService', ['$rootScope', function ($rootScope) {
var events = {
firstEvent: "MyFirstEvent",
...
1
vote
1answer
30 views
Can I use $compile in an Angular service directly on a templateUrl instead of on raw HTML or a raw angular.element?
Given the following service that is meant to create a "dialog" element (i.e. a modal):
app.service('dialog', ['$document', '$compile', '$rootScope',
function($document, $compile, $rootScope) {
...
0
votes
0answers
19 views
AngularJS model doesn't update on $state.go
I have built somewhat of a login and I want the user to be kicked to the dashboard page upon successful login. As of now, everything works as expected except for the model doesn't update until I ...
1
vote
2answers
49 views
Error: error:unpr Unknown Provider
MY MAIN CONTROLLER
var MyApp = angular.module('ionicApp', ['ionic', 'MobiNav', 'authFactory']);
CONTROLLER CONSUMING FACTORY
MyApp.controller('AuthUser', ['$scope', 'authFactoryService', function ...
0
votes
0answers
29 views
Angularjs issue in relacing Ajax request with promises in service
For my Angularjs application in services I have used Ajax call to get the data and is as follows :
var originalRequest = $.ajax({
async : false,
url : ...
3
votes
1answer
74 views
Models directly $watched and invoked by the View with Angular - a good idea?
I ran into a problem (which I think I understand), but I'm not clear about what the solution could be.
In a nutshell, I have a BackendService that wraps some non-Angular object model (in my case, ...
0
votes
2answers
37 views
How to create a factory the value of which is set at runtime and can be retrieved at runtime in AngularJS
I have to set the value of my service which provides csrf token at runtime. How do I go about this? Here is my attempt, but I see that the header X-XSRF-TOKEN is an object in the header when login ...
0
votes
1answer
39 views
Sharing data between controllers in Angular, to watch or not watch?
I read the following questions and answers:
Angular: Share data between controllers,
Update scope value when service data change,
and Angular: Update service and share data between controllers.
My ...
0
votes
2answers
26 views
template not displaying binded data after routed, on first click - AngularJS
Trying to route to different view template from the index page. Initially, the list on main index page gets loaded and the main.html gets loaded in ng-view, displaying it's text contents. The data ...
0
votes
1answer
39 views
How to store add params in api url using angular js
my angular js function code
$scope.cardcall = function (cardtype) {
$scope.cityname=cityname;
$http({method: 'GET',url: ...
0
votes
0answers
21 views
Server polling Angular js and get difference between the response
I have an api getData method which returns json data every minute in angularjs.
function($scope, $http,$timeout, confirm) {
(function tick() {
$http.get('myapi.json').success(function(data) {
...
-1
votes
3answers
60 views
How to make controller wait for promise to resolve from angular service
I have a service that is making an AJAX request to the backend
Service:
function GetCompaniesService(options)
{
this.url = '/company';
this.Companies = undefined;
...
-1
votes
2answers
103 views
Angularjs: Error: [ng:areq] Argument 'HomeController' is not a function, got undefined
This is my demo angularjs,when I create one service file, and add service to controller.
After, I have two problems:
One is when i put before
Error: [ng:areq] Argument 'HomeController' is ...
2
votes
2answers
42 views
passing params from controller to service in angularjs
I'm having trouble on figuring out how to pass parameters from my angular controller to
service
#my controller
'use strict';
angular.module('recipeapp')
.controller('recipeCtrl', ['$scope', ...
0
votes
1answer
39 views
Is it considered a bad practice to request data from the server in a service constructor in Angular?
I have an angular service that is responsible for representing a collection of employees (that happens to be stored on the database normally). I hear that it is bad code smell to do a $http.get ...
1
vote
1answer
27 views
Unknown provider: ngTagsInputProvider <- ngTagsInput
I injected the 2.1.1 version ngtagsinput like this into my controller:
app.controller('homeCtrl', ['$scope','$http','ngTagsInput', function($scope,$http){
}])
*NOTE: TESTED! add ngTagsInput into ...
1
vote
2answers
58 views
assign value of service property (Angularjs)
I try to assign a property of a service object by using the $http but I have confusing results. Why this doesn't work (here is my code):
.service('config', function ($http) {
var config = {
...
0
votes
2answers
37 views
Why not available $scope.value of the variable in runtime?
Why not available $scope.reserved of the variable in runtime? In template {{reserved}} is ок, but in controller value = undefibed.
I have the following code
Service:
'use sctict'
...
1
vote
0answers
41 views
How do you update a cached resource in an angular service?
What is a good pattern for updating angular data from a ngResource service that has been cached?
I been trawling posts like this one [1]: How to refresh / invalidate $resource cache in AngularJS, but ...
0
votes
1answer
37 views
Angularjs Rails Resource save() function not working from controller
I am using angularjs-rails-resource , in my Rails Angular App.
Account Resources
myApp.factory('Account', ['railsResourceFactory','railsSerializer', function
...
1
vote
1answer
82 views
AngularJS Interceptor Never Catches 401 Error
I'm using Angular v1.2.20 with the Ionic Framework. I have seen many articles and posts about how to handle 401 errors from the server by using an interceptor and pushing it into the ...
0
votes
1answer
41 views
Is this an appropriate use of an AngularJS Service?
I have an app with many views that are varied and numerous enough to justify dynamically loading CSS files, based on which view is active at the time.
I looked into various ways of dynamically ...
0
votes
2answers
37 views
ng-book examples not working as expected
I'm currently reading through ng-book for angular js and have come accross two example pieces of code.
The first deals with the $parse service and can be found here: http://jsbin.com/UWuLALOf/1/edit
...
1
vote
1answer
26 views
AngularJS Defining a helper function for private use in a service
I have an angular service that has one function visible to the controllers using the service. ie. getData
I want my service to be able to use a helper function called modifyData in the service that ...
1
vote
1answer
46 views
angularjs: Sharing model between controllers
I'm climbing my learning curve in angular.js and try to understand where to put everything.
In this case I want to know if it is a best practice to use services to share the model between ...
2
votes
1answer
38 views
Error in fetching records in angularjs
I am Trying to make code for fetch records in angularjs but didn't get any solution please help me
<div ng-app="" ng-controller="customersController">
<ul>
<li ng-repeat="x in ...
0
votes
1answer
32 views
AngularJS: $timeout within directive's controller using “this”
Not sure if everything is wired up here correctly. The objective is to call the nextSlide function, for it to change the class, wait a second, then incrament the current picture by 1, and then change ...
0
votes
0answers
103 views
AngularJS testing: Mocking $httpBackend - Handling Success and Error Methods
Update: I managed to further narrow down the problem scope and fix the Unexpected request error by updating the httpBackend.when request which contained some invalid ascii characters.
I have attached ...
0
votes
1answer
26 views
Ensure the proper order of subsequent HTTP ajax calls in AngularJS
Assume we have a super simple search form with autocomplete which triggers a $http.get() request on keyup/keypress:
<input type="text" ng-model="keyword" ng-change="makeRequest()">
and
...
0
votes
0answers
59 views
angularjs modal with data binding
i have to create a modal window for adding information to current controller. i used pop modal window using modalService. i'm just passing basic information.
$scope.saveCustomer =
function ...
0
votes
1answer
24 views
AngularJS $provider and $injector and bootstrapping
I've been trying to get into the nitty-gritty with angular DI and really the bootstrap process at large, and I am a bit confused as to where things really happen. In my mind, the events are in this ...
0
votes
1answer
26 views
Passing params to $resource query or get
I am trying to pass some params to a resource call to get only the votes matching those params
It seems to be ignoring those params on a query because it just returns all of the votes regardless of ...
1
vote
0answers
71 views
Override angular services during config phase for Live/Mock feature with the same app
I am trying to get my angular application work in live mode as well as in a prototype mode just by overriding the services. As a part of this when the prototype mode is turned on in the config, i halt ...
0
votes
1answer
269 views
Resource interpreted as Script but transferred with MIME type text/html when inject angular-route.map
What could be the cause of error in dependency injection of ngRouteProvider
NOTE: $location has a dependency on ngRoute, thats why I need to inject it, while, I am not really using it, but $location ...
0
votes
2answers
31 views
How to share ajax returned data between two controllers
Hi i have two controllers and in one i have defined some function to get me a data,i stored the data in $scope.data1, now i want to access this $scope.data1 data in some another named controller so ...
0
votes
3answers
40 views
AngularJs - Pass Values from view to controller then to service
I have looked at similar questions, but all don't make sense.
I have we api that i am going to use to login people. They provide the username and password, and then i query the api which returns data ...
0
votes
1answer
25 views
AngularJS view not rendered with data received in a service using routeparams
I am trying to show single trail information on trailDetails.html when I click this link on my searchTrails.html. And there is nothing on trailDetails.html. But if I move codes in getDataService.js to ...
0
votes
2answers
81 views
Stop Request in angularjs interceptor
How can I stop a request in Angularjs interceptor.
Is there any way to do that?
I tried using promises and sending reject instead of resolve !
.factory('connectionInterceptor', ['$q', ...
0
votes
0answers
31 views
Best way to handle configuration in AngularJS
Right now I have a service that runs and is injected into almost every single controller that provides a different API version string and URL string for requests based on $location's information as to ...
1
vote
1answer
56 views
How to close Angular UI Modal from anywhere
I am using the Angular UI bootstrap modal dialog and create it within a service:
myApp.factory('ModalService', ['$modal', function($modal) {
return {
trigger: function(template) {
...
0
votes
2answers
23 views
Get Post Response in Service
i am trying to post my form data via service but if i am trying to get the response in console i am finding undefined can you suggest me what mistake i am committing,
i am new to angular so finding ...
1
vote
1answer
31 views
AngularJS, Using a Service to call into a Controller
I am new to Angular, what I would like to accomplish is: From a Service / Factory to call methods directly into a controller.
In the following code, I would like from the valueUserController I would ...