Tagged Questions
50
votes
3answers
18k views
AngularJS - The correct way of binding to a service properties
I’m looking for the best practice of how to bind to a service property in AngularJS.
I have worked through multiple examples to understand how to bind to properties in a service that is created using ...
8
votes
1answer
3k views
Getting AngularJS Error: “[$rootScope:inprog] $digest already in progress” without a manual $apply
Other posts on this error always include someone trying to $apply without using a safe apply, but that's not the case in my example. My function IS successfully returning the data I requested from the ...
4
votes
3answers
8k views
Simple Angular $routeProvider resolve test. What is wrong with this code?
I have created a simple Angular JS $routeProvider resolve test application. It gives the following error:
Error: Unknown provider: dataProvider <- data
I would appreciate it if someone could ...
4
votes
1answer
2k views
AngularJS - How do I avoid using $timeout to wait for an element to be created?
Here is the idea:
So I am trying to use an external library function to create some manipulation in the DOM in one of my controllers that my ng-repeat is connected to.
Newest jsFiddle working but ...
3
votes
2answers
3k views
AngularJS: open a new browser window, yet still retain scope and controller, and services
I'm writing an angularJS app. In this particular controller, I open a new browser window through the $window.open service. But in the new window, all the $scope variables are lost.
I tried to use ...
3
votes
1answer
3k views
AngularJS Binding, multiple controllers through a service, part of page rendered from php
I know this is long, but it appears something specific in what I'm doing in the more complex scenario is causing the issue. All simple examples I attempt work fine.
I have an application setup using ...
2
votes
1answer
85 views
Angular.js sanity check: Services vs. Factories vs. Controllers… + Directives + Behavior
This article about when to use directives, services and controllers, as awesome and helpful as it is... has me massively confused about everything I think I know about the ideal structure of an ...
2
votes
1answer
62 views
Getting just an object back from an asynchronous call
My goal is
to show a username, which needs to manipulated on a web page. The mnaipulation should be done centrally in a service (MasterDataService). I want to used a scope variable on the screen which ...
2
votes
1answer
118 views
What problems would I run into if I make all Data available to all Controllers?
My AngularJS CRUD application processes it's information over a WebSocket Server. (This was mainly so that updates from one user would get automatically pushed to all users without the need for ...
1
vote
2answers
187 views
AngularJS cannot connect factory to controller
I'm sorry if this is an easy question. I'm new and probably don't understand the right things to search for to find the answer.
I've basically followed this angularJS tutorial ...
1
vote
2answers
206 views
AngularJS call common controller function from outside controller
My basic premise is I want to call back to the server to get the logged in user in case someone comes to the site and is still logged in. On the page I want to call this method. Since I am passing ...
1
vote
2answers
2k views
Initializing AngularJS service factory style
I have a service that retrieves data via REST. I want to store the resulting data in service level variable for use in multiple controllers. When I put all the REST logic directly into controllers ...
1
vote
1answer
17 views
Angular controller called twice… how to know the amount of instantiations
is a controller instantiated a second time when I declare the controller in two different DIV's? So I just want to know if the controller will be loaded twice or not like this.
Tanks in advance for ...
1
vote
1answer
59 views
Getting variable from socket.io in AngularJS
Basically i have two sources of data, one is real time data from socket.io and other is json object. And i'm using both in front-end but the problem is that i need to pass a variable from socket.io to ...
1
vote
1answer
1k views
angular js: splitting up a large controller into multiple files
I have a controller that is getting rather large.. mostly due to all the input validation I need to do. What I'd like to do is split out all the validation functions into a separate "partial ...
1
vote
1answer
580 views
Shared Variables between Controllers with a Service in AngularJS
I'm trying to share a group of variables between my controllers, but it does not seem to be working, I already followed some example but can't make it to work.
Below is the JavaScript
...
1
vote
2answers
1k views
ng-repeat not updating using $scope.$watch
I need some help in displaying the results of an update in my ng-repeat directive from $watch
ProductsCtrl is watching for a change of product type and when it detects one it searches for Products ...
1
vote
1answer
79 views
Factory property is null when accessing directly from controller Angular
I'm trying to build simple loggin with angular and rest api and I've got strange problem with checking whether user is logged in login form controller.
Here is my code:
everytime I refresh my app it ...
1
vote
1answer
105 views
Service vs Inheritance for Access Parameters Outside `ng-view`
Is it more effective to use a Service or rely on Scope Inheritance when updating parameters outside an AngularJS ng-view?
I have an AngularJS page with an ng-view and a common header. When moving ...
1
vote
0answers
400 views
AngularJS - “10 $digest() iterations reached” when ng-view ng-repeat dependant on $routeParams
I am really new to Angular and this is the first time that I am dealing with routing, so please excuse me if my questions are a bit confusing. My actual logic and structure for this app is much more ...
1
vote
2answers
733 views
How would I re-instantiate an AngularJS controller after a change in data?
I have looked, and assume this is simple, but just couldn't figure out the API documentation for this.
Assume I have a controller that pulls data when first called (I'm leaving out a ton, of course):
...
1
vote
1answer
1k views
Angular JS delay controller and directive initialization until data is returned from server
My AngularJS app requires some metadata from the server before it can initialize the controller and a handful of directives. I have a service to return the data but have been unable to get the ...
0
votes
3answers
3k views
$watch not working on variable from other controller?
I have one controller which displays a checklist, and stores the selection in an array.
My other controller runs an $http.get on the array from the first controller.
How do I set a $watch so that ...
0
votes
1answer
78 views
Sharing a variable between controllers through a service
Here is my plunker:
From what I understand, since the Service Variable being shared is an object, the object that gets loaded to the service by controller 1 should be plainly seen by controller2 ...
0
votes
2answers
193 views
No data returned in consuming REStful web service using Angularjs
I am beginner learning Angularjs .Please help me with examples for following
script added
javascript -
var app = angular.module('myapp', []);
app.controller('MyCtrl1', ['$scope', ...
0
votes
1answer
287 views
AngularJS - mechanics of $scope.$watch - is it just an observer pattern?
I have some factory:
.factory("someFactory", function() {
var someFactory = {};
someFactory.objects = [
{ name: "obj1" },
{ name: "obj2" }
];
return someFactory;
}
And some ...
0
votes
1answer
222 views
Angular controller can't get data from service
Background: I'm learning AngularJS, I've written sample code to create a service for a module, and pass the data from service into one of the module's controller, all works fine.
But yesterday when I ...
0
votes
1answer
88 views
How do I properly set a service property from model data in a controller in angularjs?
I've set up a service to share some data/state between multiple controllers. In one controller, I update some of the service properties with scope data through a save function. That data is then used ...
0
votes
1answer
1k views
Angular: call service once multiple controllers
This should be a fairly straight forward question, but I'm stumped.
I have a service that makes an http call and then does extensive post-processing of the results. I would like the processed ...
0
votes
1answer
30 views
Trying to call method in service from a controller
I'm trying to call a method in a service from a controller and am receiving the error: 'TypeError: undefined is not a function'. Does anyone see anything wrong with how I have things set up?
valid.js
...
0
votes
1answer
28 views
AngularJS Directive or Service?
My current understanding of AngularJS tells me that Directives should only contain DOM Manipulation and Services everything which has to do with logic and data handling.
In my case I'm unsure which ...
0
votes
1answer
18 views
How does service variable change update to controllers
I have a small problem and I don't understand this thing:
When I add an item to TestiFactorys arr - array it does update to both controllers
On the other hand why does not TestiFactorys arr_len ...
0
votes
2answers
192 views
AngularJs ngShow triggers double in controller
I have a problem with the controller triggering the method defined on the $scope twice when the page first loads and when the form submits.
Here's the fiddle : http://jsfiddle.net/scabro/pQb6q/5/
...
0
votes
1answer
815 views
AngularJS Factory Service Controller $http.get
I am trying to retrieve the "cart" in the following way Factory->Service->Controller.
I am making an $http call but it is returning an object. If I debug I can see that the request is made and is ...
0
votes
1answer
131 views
AngularJS remove $rootScope from a service
I have a service wrapped around WebSocket, I wanted to do it with promises and coupling requests with responses, here is what I came up with:
(function () {
var app = angular.module('mainModule');
...
0
votes
1answer
87 views
Service functions outside Angularjs scope
I have created a service in angularJS that uses btford.socket-io module to interact with the server.
Since in the service I have implemented some API that I use inside angular at the moment, but for ...
0
votes
2answers
55 views
AngularJS Services - using in Controller
I'm building a pretty simple app where I have a GlobalController (on body element), and will have another sub-controller below. This is a templated site with multiple, physical pages such that the ...
0
votes
1answer
212 views
where should i use the $http in angularjs? -> difference between factory and service
wher should i use the $http in angularjs?
in the controller or in the service?
i have already implement it in the service, but i want to execute not at the start of the app, i want to execute after ...
0
votes
4answers
2k views
Cannot get simple push/splicing of array to work - AngularJS
Please have a look at the following Plunker project.
I want to keep a list of items in a service which multiple controllers can access. In this example when you select a surname it will come up in ...
0
votes
0answers
21 views
can controllers be separate files while sharing data between controllers through a service?
I'm doing something like this:
How to create separate AngularJS controller files?
But I'm trying to share data between these separate controllers using a service. I'm unable to do it. Can you tell ...
0
votes
0answers
23 views
getting : undefined is not a function on getting collection from web-api
I have a web api which returns IHttpActionResult(myCollection) on Get.
My angular JS controller is has a function :
$scope.loadcollection = function($defer, params) {
console.log("inside ...
0
votes
1answer
34 views
How to $http.post with payload in data?
How do I post data from a form in AngularJS?
<form data-ng-submit="doSomething()">
<input type="text" data-ng-input="do_obj.text"/>
<input type="email" ...
0
votes
1answer
48 views
Update AngularJS Controller Scope from Another Controller/Scope
Hopefully this hasn't been asked.. I looked around and haven't found anything yet.
I have a single view that provides the user with a modal dialog (wizard) to create a few things and then save them. ...
0
votes
1answer
42 views
How to get the actual current controller on $routeChangeSuccess
I have a global routechangesuccess event handler for tracking route changes as "Page Loads" to our analytics platform.
Currently, I am using the current controller name in the routechangesuccess ...
0
votes
1answer
14 views
Angularjs Error: registerService.getRegisterResponse is not a function
Error: registerService.getRegisterResponse is not a function
I getting Above Error on console of the web browser. While Accessing the a method(i.e saveRegisterResponse()) from Controller (i.e ...
0
votes
3answers
60 views
Angular: Service object empty
I'm new to Angular and I've been struggling for a while trying to call a factory that uses Restangular in one of my controllers. Here is the controller:
'use strict';
angular.module('myApp')
...
0
votes
1answer
190 views
AngularJS controller scope won't sync with promise
I've picked up a project and I'm trying to return some data from a service to my controller. I've been at this for about 12 hours, and have tried different methods. They all usually result in this ...
0
votes
1answer
49 views
updating controller over service not updating view
in my app I have an "Maps" to show and handle things on maps. A CtrlMap controller display the map and shows an marker. The watchPosMap watches position changes. 3rd there is an service called ...
0
votes
0answers
293 views
excel file not getting after returning from Angularjs Service
I have situation where i have to call angularjs service method to post data to C# controller which in turns return me excel file which i want to save.
here is code....
HTML :
<div ...
0
votes
1answer
39 views
Can I give all controllers a new method that affect each controller's own scope?
In general terms
Can I make it so that all controllers have a watcher that exposes a local scope variable or a method that affects only local scope? Kind of like traits.
More specifically
Out of ...