angularjs-service

How do I prevent angular-ui modal from closing?

跟風遠走 提交于 2019-12-20 08:10:15
问题 I am using Angular UI $modal in my project http://angular-ui.github.io/bootstrap/#/modal I don't want user to close the modal by pressing on backdrop. I want a modal can only be closed by pressing close button which I have created. How do I prevent modal from closing ? 回答1: While you creating your modal you can specify its behavior: $modal.open({ // ... other options backdrop : 'static', keyboard : false }); 回答2: backdrop : 'static' Will work for 'click' events but still you can use "Esc" key

angular service available at configuration phase

╄→гoц情女王★ 提交于 2019-12-20 04:29:31
问题 I want to move some of the repetitive logic out in a reusable service, which must be available in a config phase . And possibly have access to $xxxProvider dependency injections too. Is such thing possible? Can one do this with factory/provider/service/constant ? To be specific, when I define my routes with ui-router , I noticed that routes for CRUD are all the same, except for the names of the resources. So i'd like to move this logic of configuring a CRUD route somewhere to make route

$watch not working on variable from other controller?

余生颓废 提交于 2019-12-19 10:16:56
问题 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 whenever the array changes, a new HTTP GET request is sent? My attempt: http://plnkr.co/edit/EaCbnKrBQdEe4Nhppdfa // See plnkr for other controller + FooSelection factory + view function SimpleQueryResCtrl($scope, $http, FooSelection) { $scope.foo_list_selection = FooSelection; $scope.$watch('foo

Can I use $compile in an Angular service directly on a templateUrl instead of on raw HTML or a raw angular.element?

五迷三道 提交于 2019-12-19 06:44:13
问题 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) { var body = $document.find('body'); var scope = $rootScope.$new(); this.createDialog = function() { var dialogElem = angular.element('<div ng-include="\'/dialog.html\'"></div>'); $compile(dialogElem)(scope); body.append(dialogElem); }; } ]); which can be utilized in a controller like so: $scope

Can I use $compile in an Angular service directly on a templateUrl instead of on raw HTML or a raw angular.element?

走远了吗. 提交于 2019-12-19 06:43:59
问题 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) { var body = $document.find('body'); var scope = $rootScope.$new(); this.createDialog = function() { var dialogElem = angular.element('<div ng-include="\'/dialog.html\'"></div>'); $compile(dialogElem)(scope); body.append(dialogElem); }; } ]); which can be utilized in a controller like so: $scope

AngularJS: service query returning zero result

∥☆過路亽.° 提交于 2019-12-18 16:57:30
问题 my app.js looks like var app = angular.module('pennytracker', [ '$strap.directives', 'ngCookies', 'categoryServices' ]); app.config(function($routeProvider) { console.log('configuring routes'); $routeProvider .when('/summary', { templateUrl: '../static/partials/summary.html'}) .when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' }) }); while my app/js/services/categories.js looks like angular.module('categoryServices', [

AngularJS: service query returning zero result

梦想的初衷 提交于 2019-12-18 16:57:15
问题 my app.js looks like var app = angular.module('pennytracker', [ '$strap.directives', 'ngCookies', 'categoryServices' ]); app.config(function($routeProvider) { console.log('configuring routes'); $routeProvider .when('/summary', { templateUrl: '../static/partials/summary.html'}) .when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' }) }); while my app/js/services/categories.js looks like angular.module('categoryServices', [

angularjs: using service to communicate between controllers

谁说胖子不能爱 提交于 2019-12-18 07:11:42
问题 I have a service that is injected in my controllers. The service defines a number of functions. Now I would like to add a variable to that service that would hold the selectedItem in the application. I've done it this way: angular.module('myservices', []). factory('serviceA', function () { var serviceA= { selectedItem: selectedItem, ... more functions here }; return serviceA; var selectedItem; ... functions go here }); In one of my controllers I set the selected item: serviceA.selectedItem =

Initialize $scope variables for multiple controllers - AngularJS

99封情书 提交于 2019-12-18 05:15:13
问题 I have 3 controllers that do similar tasks: PastController queries an API for past system outages. CurrentController queries an API for current system outages FutureController queries an API for future system outages They are each unique (despite their similar functions). However, they all begin by defining the same $scope variables: app.controller("PastController", function ($scope) { $scope.Outages = ""; $scope.loading = 0; $scope.nothing = 0; $scope.error = 0; //--- code continues ---// })

Passing asynchronously obtained data to a directive

假如想象 提交于 2019-12-18 05:10:15
问题 I currently have an AngularJS controller that is basically getting some JSON asynchronously through a $http.get() call, then linking the obtained data to some scope variable. A resumed version of the controller code: mapsControllers.controller('interactionsController', ['$http', function($http) { var ctrlModel = this; $http.get("data/interactionsPages.json"). success(function(data) { ctrlModel.sidebar = {}; ctrlModel.sidebar.pages = data; }). error(function() {...}); }]); Then, I have a