Tagged Questions
0
votes
0answers
14 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
10 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
22 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
25 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
17 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 ...
0
votes
2answers
23 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
25 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
73 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
31 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
37 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
20 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
20 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
2answers
47 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
89 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
41 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
38 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
26 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
55 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
36 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
39 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
29 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
70 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
32 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
24 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
43 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
31 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
86 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
24 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
55 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
20 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
25 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
60 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
200 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
30 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
37 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
24 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
69 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
28 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
54 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 ...
1
vote
0answers
33 views
Angularjs factory/service management
We are working on a large scale application based on angularjs, now based on some best practices we develop a model using factory services, such that it can be shared across controllers. Since, we ...
0
votes
0answers
32 views
angularjs - $resource cookie phpsessid changes every server request
I use $resource to login to a (Yii) php backend. After the login I want to retreive all cars (for example). BUT the received cookie, contains a different PHPSESSID every request. How can this problem ...
0
votes
1answer
35 views
How do you inject dependencies into services in angular.js?
I'm using AngularFire to create a web app. Several of my controllers use a lot of the same functions to access the data in Firebase, so I am trying to write a service so that I don't have to rewrite ...
0
votes
1answer
21 views
view not updated when using $http in service
I have an angularJS application with 2 controllers and one service to exchange data between controllers.
Controller 1 "controls" an angluarjs-map an provides the map-metadata for the view.
A ...
0
votes
1answer
43 views
AngularJS why can't I use share a provider with another module?
I have a App module that has many component modules that are injected into the App module. The App module has a provider that I would like to use inside of the component modules, but I am receiving an ...
0
votes
2answers
90 views
How to stop execution of Controller with $routeChangeStart in angularjs
I am setting session on login and after that I am preventing LoginCtrl to be called as it is resetting session.
I have a setup of routes where if any undefined route is called it takes to /login But ...