Tagged Questions
0
votes
0answers
42 views
How can I download a file using AngularJS?
I want to list all the files(from a directory) in the view. When I click anyone of them. Then the corresponding file must be downloaded.
Note: I am working in a windows machine.
I have the following ...
0
votes
1answer
20 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
4answers
45 views
How to display JSON list data in angularjs
I am new to Angularjs and having trouble displaying data . i.e. Json array
This is the result of my rest service call:
...
0
votes
0answers
15 views
Is service dependency mandator if implementation enviroment contains the dependency (I.E controller has dependency)
Is a dependency added to service when it will be used in a controller with the dependency already injected.
The service :
myServices.factory('firebaseWritejournalUser',['',function() {
...
-1
votes
0answers
11 views
save login info to rootscope before app loads
My app needs login information returned from server before loading the appropriate templates for my app. I was thinking of saving the login info in the $rootscope so whenever the user is navigating ...
0
votes
0answers
24 views
Share one function in one service to the second service in angular js
I have a module in AngularJS. I have two controllers (app.factory) who help to the module in validations etc.
I have one function of validation in controller 1 and i need it also in controller 2.
...
0
votes
1answer
29 views
Capturing response on failure in angular js?
I am novice and working on angular for first time.I am calling one service in angular. When the call is successful it gives me the response like User name and his log in information. When call is fail ...
0
votes
1answer
15 views
it's right this service AngularJS
My service don't work. I am not sure if it's right or not.
I want The service to add items when the app runs , and their other function it's for add another textbox, but the million question is the ...
2
votes
3answers
39 views
unable to get data from $q into scope
I'm trying to bind some data being returned from an API to my scope using promises with $q, I am able to pull the data from the server without any issue (I can see JSON being returned using fiddler) ...
1
vote
1answer
36 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 ...
0
votes
1answer
23 views
angularjs directive isolated scope within link method
My jsbin is here: http://jsbin.com/yapi/1/edit
I am testing the isolated scope within link method of the directive (it works when used within template instead).
My goal is that link method in ...
0
votes
1answer
54 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
2answers
106 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 ...
0
votes
2answers
83 views
Access stored data in an Angular factory after a $http call
I am trying to build a factory to act as a staging area for my database models, as well as an api to perform basic CRUD calls. I want to be able to access data by storing it in a service or a factory, ...
0
votes
1answer
64 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 ...
1
vote
2answers
96 views
AngularJS creating (and binding) form elements dynamically based on API response
I'm trying to create a member's form with all the pre-defined phone types.
I'm making two api requests for member and phone types. Here is what I've:
First request with member's information:
...
0
votes
2answers
38 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
372 views
AngularJS Bind service array variable to controller scope
I have been able to properly bind an object with primitive data from a service to a scope variable from a controller but I'm having trouble doing the same thing with an array variable from the ...
0
votes
1answer
389 views
AngularJS not updating template variable when scope changes
This will be one of those stupid questions that is very obvious to the experts.
I have a websocket pushing data to a service where I'm trying to store the data and have it pushed to a template via my ...
1
vote
2answers
72 views
Data-binding from external HTTP API wrapped in a service does not work
I have a problem binding data from an external HTTP API. I tried to follow best practices and tried several approaches (reading the Internet and SO), but the "magic" of data-binding doesn't work and I ...
0
votes
1answer
71 views
Angularjs call synchronization
I am using angularjs get method to get array of feeds from server. here is my controller code.
$scope.feeds = new Array();
$scope.feeds = FeedService.getFeeds();
console.debug("in controller ...
2
votes
1answer
59 views
Storing generic controller function in services in order to get them in isolated scope
I have an Angular UI modal that I would like to use the following method on, I used to keep it on the controller that wraps my entire application(metaCtrl), but the modal seems to create his own ...
4
votes
1answer
241 views
AngularJS - Deep object' property deletion
I know how to set object' "deep" property with $parse service , like in this post.
But how can i delete a deep property ? Not assign it to null with this:
...
1
vote
0answers
90 views
In Angular JS, can we use ng-controller twice? [closed]
I' am trying to develop an web application using Angular JS. I' am trying to create two Angular JS controllers in the same page but things seems to be not working. Please can someone tell me where I ...
0
votes
1answer
114 views
ngModel' deep objects creation mechanism
I want to use angular' mechanism for deep property nesting , something that ng-model directive is using. I mean we can create very "deep" object in a scope by writing : ...
2
votes
2answers
111 views
Firefox sending multiple XHR requests when binding a controller function to the DOM
I have the following function in my controller:
$scope.model.listApplicantStatuses = function(){
var statusChoices = jobsService.getApplicantStatuses();
if(statusChoices !== null)
...
4
votes
1answer
2k views
AngularJS Directive not able to access isolate scope objects
I am trying to put some default values in my directive with Isolate scope. Basically, I need to do some DOM manipulations using the scope object when my directive is bound. Below is my code:
...
4
votes
2answers
373 views
Angular directive not picking up service data
My service NavData
angular.module('navData', []).
factory('NavData', function() {
var navData = {};
navData.depth = 0;
navData.category_id = "";
...
0
votes
2answers
233 views
Loss of references between service and controller data in Angular.js
We encountered a problem when working with references between service and controller data
// We have a service that we use to store id and some other data
app.service('testService', function ($http, ...
0
votes
1answer
444 views
Sharing a webservice's data across controllers in AngularJS
I have 2 big issues with an Angular app, I'm completely stuck and hoping someone out there can help me.
My method of sharing data from a web-service out to multiple controllers is flawed and I don't ...
3
votes
1answer
2k views
AngularJS factory property isn't being updated in $scope when not using push()
I have a factory that is retrieving the data from an external source. As soon as i get the data, i use a second factory to filter it by a certain criteria.
The factory property is assigned to scope.
...
0
votes
2answers
953 views
Share async data between controllers without making multiple requests
I'm trying to make a single $http request to one of my json file and use the data across all my controllers.
I viewed on egghead.io how to share data across multiple controllers, I've also read this ...
2
votes
2answers
321 views
Issues binding / watching service variable shared between two controllers
I am having a really hard time deciphering what is going on here. I understand the basics of Angular's $digest cycle, and according to this SO post, I am doing things correctly by simply assigning a ...
0
votes
1answer
1k views
AngularJS share asynchronous service data between controllers
I know this issue has been asked several times in stackoverflow, but I couldn't find a proper answer.
What I need to achieve is to be able to initiate some asynchronous call in one controller and ...
0
votes
1answer
154 views
angularjs: using $watch in directive to call serivce
I am creating a directive that does a two day binding with an input box.
a $watch is placed inside link function(which i don't know if this is a good idea) to watch the value in the input box.
it ...
0
votes
2answers
66 views
Angularjs first attempt at dependency injection
I have a UserAddController and I want to be able to access a list of countries returned by a Web API. The Web API returns data fine. Here is my app.js where I get the data :
app.factory('Country', ...
1
vote
1answer
648 views
Best (idiomatic) way to refresh data from a service in AngularJS
I am facing a "problem" with AngularJS, services and scope.
It is not really a problem (I found a couple of ways to make it work), but I would like to know if I am doing the right thing, or if what ...
1
vote
2answers
2k views
AngularJS Wait for scope variable to evaluate from custom directive
I'm staring my way in AngularJS.
I have created a custom directive:
app.directive('myScroll',function(){
return {
restrict: 'A',
transclude: true,
template: '<div ...
0
votes
1answer
239 views
Angularjs models not binding to json template used in http post request
I have a static/variable json request template of sorts that I'm using when sending a $http POST request from a controller via a $http post factory. The problem is that model data, which is in scope ...
0
votes
0answers
62 views
Extend rootScope with alert service?
I can easily envision myself injecting my alert service into almost every one of my controllers:
myApp.factory('AlertsList', function () {
return [{ type: 'info', msg: 'Welcome!'},
...
1
vote
2answers
905 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 ...
5
votes
1answer
176 views
AngularJS philosophy - controllers as “windows” to services
Sorry for the vague title;
I've been restructuring some of my AngularJS code, trying to be more "Angular" about it, and I've noticed this pattern popping up quite a bit:
app.service("someService", ...
0
votes
1answer
59 views
Recycling AngularJS functions
I am pretty new with AngularJS, but was wondering how to create commonly used functions outside the scope of a controller.
For example, I pretty often need to call a function to start a "Loading" ...
0
votes
2answers
158 views
Passing service between controllers and directives
I have a single service defined as follows:
angular.module('myApp')
.factory('myService', function ($resource, $q) {
mySource = [];
EndPoint = $resource('/my/api/endpoint', ...
5
votes
3answers
5k views
AngularJS: How to pass values from Controller to Service Method?
I have a controller which is dependent on a TransactionService. One of the method is
$scope.thisMonthTransactions = function () {
$scope.resetTransactions();
var today = new Date();
...
3
votes
2answers
228 views
Single page app, permalinks and ngView?
This is my current setup, with each column being represented by a controller:
<navbar></navbar>
[column1] [column2] [column3]
<footer></footer>
Additionally each column has ...
0
votes
3answers
2k 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
1k views
Understanding $watch in AngularJS? [duplicate]
I am a little confused with the $watch syntax in AngularJS.
Given a variable $scope.foo, with initial value of [1,2,3], and update causes it to now equal [1,2]. I want a function to be run whenever ...
0
votes
1answer
499 views
AngularJS deferred specific behavior inside the scope
Assume that we have a bit of html like that:
<button
id="my-login-button"
ng-hide="loggedIn"
ng-click="login()">Log me in!</button>
Also we have a JavaScript:
// controller.js
...
1
vote
2answers
2k views
AngularJS: PUT send data with URL but not as JSON data
Here is my UserService
angular.module('userServices', ['ngResource']).factory('User', function($resource) {
return $resource('/users/:userId',
// todo: default user for now, change it
...