angularjs-module

Angular Module Private Members

元气小坏坏 提交于 2019-12-01 16:54:00
问题 In AngularJS, is it possible to create private controllers or services which can be used within the module they are defined in, but not by another module they are injected into. For example, can PrivateController be made private to the Child module: angular.module('Child', []) .controller('PublicController', function ($scope){ $scope.children = ['Bob', 'Sue']; }) .controller('PrivateController',function ($scope){ $scope.redHeadedStepChildren = ['Billy', 'Mildred']; }) angular.module('Parent',

AngularJS Modules and External Controllers

走远了吗. 提交于 2019-12-01 13:27:28
I have a page containing multiple containers. Each container will have its own controller but point to one factory, which handles all the logic interacting with a web service API. I would like to have a separate file for each controller BUT I want all of this inside of one module. for the life of me I cannot find how to include controllers from different files into one modules. //file 1 MyController .... //file 2 MyOtherController //file 3 MyFactory //file 4 The Module The module would be composed of MyController, MyOtherController and MyFactory defined in three separate files. Can someone

How should I make configurable modules in AngularJS

久未见 提交于 2019-11-30 18:04:40
I've been tinkering with AngularJS and I've built up a small collection of directives and services that I would like to package into a single JS file so that I can use them anywhere. I have some website specific settings that my module will need for API calls and that sort of thing. I'm just wondering what the Angular way of making configurable modules is. Obviously I don't want to have to modify my reusable JS file for each website, as that kind of defeats the purpose of having it. Seeing as the values are going to remain the same for each website it seems like an awful lot of hassle to pass

Correct way of wrapping javascript class in AngularJS module and inject angular services

别说谁变了你拦得住时间么 提交于 2019-11-30 15:38:34
Inside an AngularJS module I'm developing, I have a Canvas class defined as: angular.module("myModule", []) .factory("Canvas", function() {return Canvas;}); var Canvas = function(element, options) { this.width = options.width || 300; this.height = options.height || 150; this.HTMLCanvas = $(element).get(0); this.HTMLCanvas.width = canvas.width; this.HTMLCanvas.height = canvas.height; this.objects = []; //Initialize canvas this.init(); } Canvas.prototype.init = function() {/*...*/}; Canvas.prototype.otherMethod = function() {/*...*/}; Now, the Canvas class is never instantiated from inside the

How to check for the existence of a module without an error being raised?

淺唱寂寞╮ 提交于 2019-11-30 10:44:26
问题 In Angular 1.2, ngRoute is a separate module so you can use other community routers like ui.router instead. I'm writing an open-source module that aims to work for multiple different router implementations. So how can I check which router is loaded or exists? I'm doing the following inside a factory in my module, but it does not work the way I expect it to: if (angular.module("ngRoute")) // Do ngRoute-specific stuff. else if (angular.module("ui.router")) // Do ui.router-specific stuff. It

AngularJS - module dependencies, naming clash

匆匆过客 提交于 2019-11-29 22:12:48
I have two third-party modules, both defining a factory with the same name. Obviously, I don't have any control over the naming of those modules without resorting to a kludge. Additionally, I have two further, internal modules, each using a different one of the two third-party modules as a dependency (as below). I was sure that I was unable to access components from a module not listed in current module's dependencies, but it turned out I was wrong. Here even if own1 depends on thirdParty1 (which has hello defined as hello world ) it's getting hi there (from thirdParty2 ) in controller. The

AngularJS Modules/Scope Sharing

安稳与你 提交于 2019-11-28 21:40:31
I recently started using AngularJS and the way I'm building my apps now is like this: MainController.js var app = angular.module('app', ['SomeController', 'MainController']); app.controller('MainController', function ($scope) { // do some stuff } SomeController.js var SomeController= angular.module('SomeController', []); SomeController.controller('SomeController', function ($scope) { $scope.variable = "test"; // do some otherstuff } The problem that Im' running into is that the scope is not being shared between modules. From MainController I can't get the variable "test" for example. What is

AngularJS - module dependencies, naming clash

孤人 提交于 2019-11-28 18:35:13
问题 I have two third-party modules, both defining a factory with the same name. Obviously, I don't have any control over the naming of those modules without resorting to a kludge. Additionally, I have two further, internal modules, each using a different one of the two third-party modules as a dependency (as below). I was sure that I was unable to access components from a module not listed in current module's dependencies, but it turned out I was wrong. Here even if own1 depends on thirdParty1

is there a way in Angularjs to define constants with other constants?

匆匆过客 提交于 2019-11-28 15:15:51
I'm trying to define constants with other constants, but it seems that it can't be done, because the initial constant isn't ready when the required constant depending require it. I want to be sure if this isn't possible at all. Currently I have constants in this way: angular.module('mainApp.config', []) .constant('RESOURCE_USERS_DOMAIN', 'http://127.0.0.1:8008') .constant('RESOURCE_USERS_API', 'http://127.0.0.1:8008/users') // Specific routes for API .constant('API_BASIC_INFORMATION', RESOURCE_USERS_API + '/api/info') .constant('API_SOCIAL_NETWORKS', RESOURCE_USERS_API + '/api/social') ; The

AngularJS Modules/Scope Sharing

↘锁芯ラ 提交于 2019-11-27 14:16:52
问题 I recently started using AngularJS and the way I'm building my apps now is like this: MainController.js var app = angular.module('app', ['SomeController', 'MainController']); app.controller('MainController', function ($scope) { // do some stuff } SomeController.js var SomeController= angular.module('SomeController', []); SomeController.controller('SomeController', function ($scope) { $scope.variable = "test"; // do some otherstuff } The problem that Im' running into is that the scope is not