angularjs-service

is there a way to update filter with async data

二次信任 提交于 2020-01-04 13:51:08
问题 I had build the next angular filter: App.filter('cur2symbol', ['CurrenciesService', function (CurrenciesService) { return function (input, iso) { input = input || ''; iso = iso || 'ILS'; var symbol= CurrenciesService.getCurrencySymbolByIso(iso); return symbol+input; }; }]) the meaning of this filter is to get currency iso code and convert is to symbol for examle: the next code {{200|cur2symbol:"ILS"}} will output ₪200 . My problem is that the CurrenciesService service is Async, so the filter

Why does this AngularJs Service with variable object name return an undefined object?

人盡茶涼 提交于 2020-01-04 02:35:19
问题 Scenario : I'd like to use this service to share some properties inside my webApp. This service should have some object inside and the controllers should be able to get and set those objects. JS : var oneApp = angular.module('myApp', ['ui.bootstrap', 'ngTouch', 'ngAnimate']) .service('sharedProps', function() { var anObjNameDest = ''; var anObjPropName = ''; this.progressBarDynTyped00 = { dynamic: 0, dynMultiplier: 10, max: 100 }; var progressBarDynTyped00 = { dynamic: 1000, dynMultiplier:

Angularjs - Declaring factory with a single object with a nested array - getting ReferenceError: … is not defined

一曲冷凌霜 提交于 2020-01-03 05:00:08
问题 I have a factory with several different methods and I am trying to declare an object that has an array nested in it. That one nested array will be the main driving force for my app and it will have nested arrays as well(many more). However, I do want the nested array to stay nested in that one object. I tried the following but I keep getting error that myObject is is undefined. app.factory('myService', function() { return { myobject: {name: "MockName", version: "1", myArray: []}, addToArray:

How to pass in a JSON object to a resource in angularjs

风格不统一 提交于 2020-01-03 02:59:29
问题 I would like to use a web-service that takes in JSON object (The object binds two arrays) in a POST request and returns a JSON object array. I would now like to send request to the webservice from my AngularJS. Here is my code: wellApp.factory('Search', ['$resource',function($resource){ return $resource('/filetables/searchdata/:tagSearchInput', { }, { searchData:{ method:'POST', isArray: true, params:{ tag: '@tagSearchInput.tag', details: '@tagSearchInput.details' } } }) }]) function

AngularJS share asynchronous service data between controllers

断了今生、忘了曾经 提交于 2020-01-02 20:08:26
问题 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 when the result returns update the $scope in some other controller. I understand that I should use a shared service that actually does the $http stuff, but I can't manage to update the other controller scope. Here is my code: View <div class="screens" ng-controller="framesController"> <div class=

AngularJS Informer service

不羁的心 提交于 2020-01-01 10:53:35
问题 I'm using Twitter Bootstrap for UI in my webapp. Particulary its Alert component. I want to write a simple angular service to wrap Bootstrap's Alert to have a possibility of informing users from any peace of angular code. Like this: Informer.inform("message", "ERROR"); // will result in alerting with `alert-error` class Informer.inform("message", "INFO"); // will result in alerting with `alert-info` class My idea is to to append the template to the end of the <body> : <div class="alert {

AngularJS Informer service

谁说我不能喝 提交于 2020-01-01 10:52:31
问题 I'm using Twitter Bootstrap for UI in my webapp. Particulary its Alert component. I want to write a simple angular service to wrap Bootstrap's Alert to have a possibility of informing users from any peace of angular code. Like this: Informer.inform("message", "ERROR"); // will result in alerting with `alert-error` class Informer.inform("message", "INFO"); // will result in alerting with `alert-info` class My idea is to to append the template to the end of the <body> : <div class="alert {

Possible to use a custom Angular service before bootstrap?

拈花ヽ惹草 提交于 2020-01-01 06:12:09
问题 I have a service: angular.module('USC').service('TemplateService', function() {}); That I would like to use before I manually bootstrap my Angular project: angular.bootstrap(document, ['USC']); Is this possible? I know I can call var service = angular.bootstrap().get(); for Angular provided services, but how would I call a custom one before the module was initialized? 回答1: If it is OK to have a different instance of the service than the one that will be used by the app itself, you can achieve

AngularJS service retry when promise is rejected

本小妞迷上赌 提交于 2019-12-29 03:15:09
问题 I'm getting data from an async service inside my controller like this: myApp.controller('myController', ['$scope', 'AsyncService', function($scope, AsyncService) { $scope.getData = function(query) { return AsyncService.query(query).then(function(response) { // Got success response, return promise return response; }, function(reason) { // Got error, query again in one second // ??? }); } }]); My questions: How to query the service again when I get error from service without returning the

Firebase data normalized. How should I fetch a collection based on this structure?

徘徊边缘 提交于 2019-12-28 03:38:11
问题 I think I am getting close, I am able to print out the ID of books belonging to a user but have been trying unsuccessfully to fetch the list of books belonging to a user, from the firebase books reference. I'm following loosely the tutorial here: http://www.thinkster.io/pick/eHPCs7s87O/angularjs-tutorial-learn-to-rapidly-build-real-time-web-apps-with-firebase#item-526e9330d90f99661f00046c and also reading the documentation about denormalizing data here: https://www.firebase.com/blog/2013-04