w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Is it possible to create an AngularJS service without a module?
Quoted from the doc of Creating Services To register a service, you must have a module that this service will be part of. So I guess the answer is no.

Categories : Angularjs

How to create an AngularJS service that is accessible from the default app / custom module
You can add components to the ng module, which is the default module, with angular.module("ng").service(...). As mentioned in the comments, this is a bad idea for several reasons, most prominently that the Angular team might provide a service with the same name later. For reference, the preferred way is to define your own module such as myAwesomeDataModule and add it as a dependency in other modules: angular.module("myModule", ["myAwesomeDataModule"]).

Categories : Angularjs

Resource based routing module used in a Node.js REST API service, or other useful modules for this type of service
RESTfull API get and post data through HTTP protocol. A more progressive approach is to use WebSocket [Wikipedia] npm link. Try to play with Sails.js framework build on Express.js that use Socket.IO for flash data transfering

Categories : Javascript

Import python module over the internet/multiple protocols or dynamically create module
In principle, yes, but all of the tools built-in which kinda support this go through the filesystem. To do this, you're going to have to load the source from wherever, compile it with compile, and exec it with the __dict__ of a new module. See below. I have left the actually grabbing text from the internet, and parsing uris etc as an exercise for the reader (for beginners: I suggest using requests) In pep 302 terms, this would be the implementation behind a loader.load_module function (the parameters are different). See that document for details on how to integrate this with the import statement. import imp modulesource = 'a=1;b=2' #load from internet or wherever def makemodule(modulesource,sourcestr='http://some/url/or/whatever',modname=None): #if loading from the internet, you'd

Categories : Python

Angularjs how can I unit test a Service which depends on another Service with promises?
If you are just testing Service2 then you should try to eliminate any dependency on Service1 in the test. Your test could have something like: module('foo.services', function($provide) { $provide.value('Service1', MockService1()); }); This will give the return value from the function MockService1 instead of actually using the service, whenever it is injected. Then you have MockService1 function return a skeleton of the actual service with the same function. In your test you can then wait for the promise to be resolved by doing something like this: bar: function(...) { var def = $q.defer(); $timeout(function() { def.resolve('test'); }); return def.promise; } // This is in your test bar.then( // .... some tests); // This executes the timeout and therefor the resolve $root

Categories : Unit Testing

AngularJS broadcast from one service not triggering a call to second service
Figured it out; I had to call $scope.$apply(), like this: function ReceiverCtrl($scope,$rootScope,$routeParams,ytplayer,ytdataapi) { $scope.$on('loadedApi',function () { ytdataapi.search("",{'topicId':$routeParams.topicId,'type':'video','maxResults':1,'order':'viewCount'}).success(function(apiresults) { ytplayer.videoId=apiresults.items[0].id.videoId; ytplayer.loadPlayer(); }); $scope.$apply(); }); } Is there anyone who could shed light on why this works, though? $scope.$digest() also works ... but I thought those methods were only used when you need to update bindings because of some javascript code that Angular isn't aware of. Is the nesting I've got here doing that (I wouldn't think it should, as my ytdataapi service is using $http)?

Categories : Angularjs

AngularJS - SOAP Service Integration With AngularJS Model
I guess the best way would be to implement it as a $http interceptor. I did it in our project and it worked great because the angular $http calls stay the same. This is a link to the provider I created for our project : http://jsfiddle.net/gqp9m/ I did some copy-paste from the soapclient library and moved it into a provider. I also changed a bit of the syntax so the code will pass jsHint. Most of the modified function are commented with documentation notes. It also requires jQuery (for the $.parseXML function - you can refactor it to remove dependency in jQuery). The biggest difference is that my code does not load the wsdl on first request, but rather needs you to cache it before making any call, like so : myModule.service(['myModule.soap-interceptor', function(soap){ $http.get('ht

Categories : Javascript

Adding service reference for WF4 workflow service doesn't create client (ClientBase)
For anyone caught in this one, here's the issue. I had generated the web references for a console service app. By default, these are implemented as workflow activities, not as part of a client wrapper. Once I realized my misunderstanding, instantiating was simple.

Categories : Visual Studio 2012

Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]
I can try to answer your problem, but your question should include more information: You should include a full stacktrace. There is not enough information in the error you put in your question. The full stacktrace will add some necessary information to help us figure out what's going on. You post one configuration file, but it refers to other files, like hibernate.properties. You should include these files so that we can check the correct configuration of your application. Without this information, I can just suggest the following: You are using Atomikos as transaction manager. You must include a Maven dependency to Atomikos (you say in your post that you are using Maven). In the declared bean usermanagementSessionFactory, you should have properties in relation with Atomikos, as it i

Categories : Spring

Create C# client consumes SOAP service without using built-in 'Add Service Reference...'
You can do it by creating SOAP message and sending web request Like in this SOAP client web request

Categories : C#

Ruby: gem win32-service: Create a service with Admin privileges
The underlying CreateService Windows API function requires an account domain on the lpServiceStartName field, so you probably need to set the :service_start_name field to 'domainAdministrator', where the account domain is usually the computer name.

Categories : Ruby

Do I need to create a module for: A user account, to create and save custom "objects" made of choices from a form
Drupal is great for such a project. And you don't need too much extra modules, just core modules. 1) Core user module is fine. 2) Node type A. Create the node with the described fields and a user Role that will be able to add new A nodes as also as edit/delete own A nodes. 4) Node type B. Just add relationship for the Node type A so users can make the connection. Use the EntityReference module here. Similar user role permissions here. 6) This needs more information but it seems you need to use Views module to achieve this. 7) Welcome to Drupal! This is a core functionality also.

Categories : Forms

Use other service from a service method in AngularJs
The $scope service is unique to Controllers (and directives, but in directives it isn't being injected). Try another service name which you defined in another factory or just any other angular service like $http and it will work...

Categories : Javascript

How to create osx service that passes its service name to shell script?
"Basically my aim is to open a browser with an URL which is different for each of the menu item." Something like the following AppleScript can be used to open a URL in the default web browser, using AppleScript: tell application "Finder" to open location "http://learnbymac.com" Something like the following shell script can be used to open a URL from the shell: open -a "Finder" "http://learnbymac.com" Using the Finder to open URLs is better than using Safari because when you use the Finder to open URLs, you get the default browser rather than always getting Safari. " i will launch an app / exe from the shell script by passing path to the file & service name so that the app can construct url based on the service name by reading the file details from the data base and loads

Categories : Osx

What is module in Angularjs?
General remark for beginners: forget that tutorial and start by this instead (from the egghead videos on -- I am still learning, too). The module is your application in which you can register directives, controllers, services, filters, .. You can use different modules and inject them into your main module (this is helpful to have a clearer structure.. and to use third party modules as libraries).. angular.module('myApp', [ 'myApp.controllers', 'myApp.filters', 'myApp.services', 'myApp.directives', // 3rd party dependencies 'ui.bootstrap', 'btford.socket-io' ]). This is a snippet from a project I am working on: myApp is the main module I am using (in the html file <html ng-app="myApp">), myApp.xxx are other modules whic

Categories : Java

Error using module in angularJS
You need to include <script type="text/javascript" src="http://code.angularjs.org/1.0.6/angular.min.js"></script> before <script type="text/javascript" src="hotel_listing_angular.js"></script>

Categories : Angularjs

AngularJS Module Configuration
app.config, as you might have noticed, won't allow you to use services like $http (or any service you make yourself), it's run before they are defined. Try putting the call in your app.run instead. It is after config and it has no restrictions against using services. If it is the right approach or not is harder to answer as it depends on the exact use-case. As $http-calls are asynchronous you cannot just call your backend when the app starts and be sure the token exists in your controllers or services, the http call might not have returned yet! This might be a problem for you if you expect to use the token right away. A better option, again depending on use-case, might be to use a resolve-function on any route that needs the token. A route will holds off on loading any controller and tem

Categories : Javascript

AngularJS - Getting Module constants from a controller
I don't think it is valid to use the module name in an injection like that. You can simply inject the constants by name, though: angular.module('myApp.controllers', ['myApp.config']) .controller('ListCtrl', ['$scope', 'APP_NAME', function($scope, appName) { $scope.printme = appName; }]);

Categories : Javascript

AngularJS: Provider after Module.config?
You might want to consider creating separate modules. This will not only allow give you the flexibility you are looking for, it will help to make your code easier to test and maintain. angular.module('myModule', ['myModule.controllers', 'myModule.services']).config(function (myServiceProvider) { myServiceProvider.setName('Sam'); }); angular.module('myModule.controllers', []).controller('myController', function ($scope, myService) { $scope.name = myService.getName(); }); angular.module('myModule.services', []).provider('myService', function () { var name = 'John'; this.setName = function (newName) { name = newName; }; this.$get = function () { return { getName: function () { return name; } }; }; });

Categories : Angularjs

Sub-Application module organization with AngularJS
If your modules are small and not related then better way is to create multiple instances of AngularJS applications and bootrstrap them separately. The advantages of such approach are: performance: separated $digest phases for each application separated css and minified js files for your applications separation of $rootScopes and variables still you can use your applications as modules with larger application You can bootstrap each application using manual method: <!doctype html> <html xmlns:ng="http://angularjs.org"> <head> <script src="http://code.angularjs.org/angular.js"></script> </head> <body> <div id="portlet1"> Hello {{'World1'}}! </div> <script src="apps/app1.js"></script> <div id="portle

Categories : Javascript

Angularjs : How to configure each module for routing
It is as simple as this: angular.module('myApp', []) .config(['$routeProvider', function($routeProvider) { // Do the routing here. }]) You can do the same for each module, instead of maintaining routes for all modules in a single common file.

Categories : Angularjs

AngularJS lazy module definition
Not sure this is what you will need but you can do something like that In a dedicated file create this : // Bootstrap.js angular.module('com.mysite.services', ['com.mysite.services.ServiceA', 'com.mysite.services.ServiceB', ....]); And now for every service you can do something like // ServiceA.js angular.module('com.mysite.services.ServiceA', []). service('ServiceA', function(){}); //ServiceB.js angular.module('com.mysite.services.ServiceB', []). service('ServiceB', function(){}); You can now depend on 'com.mysite.services' in your app and all your services will be made accessible.

Categories : Javascript

Adding new Module is not working in angularjs
Make sure that in your file loader (script tags, requirejs, whatever) Controllers1.js is right next to controllers2.js. PS: some operating systems / webservers (e.g. the server inside karma on windows) are case sensitive. So try to use same case for your files (either upper or lower).

Categories : Angularjs

Error in Hibernate Tool in Eclipse Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
I write here as in comments is difficult to be clear. In the class org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator put a breakpoint in the method below, in the return statement. It causes the exception thrown in your runtime. In debug mode we will understand what is happening and ,hopefully, complete this reply: private ConnectionProvider More ...instantiateExplicitConnectionProvider( String providerClassName, ClassLoaderService classLoaderService) { try { LOG.instantiatingExplicitConnectionProvider( providerClassName ); return (ConnectionProvider) classLoaderService.classForName( providerClassName ).newInstance(); } catch ( Exception e ) { throw new HibernateException( "Could not instantiate connect

Categories : Java

Accessing factory defined in another module in angularjs
You need to inject MyServiceModuleTwo into MyServiceModule: var myModuleTwo= angular.module('MyServiceModuleTwo',[]); var myModule= angular.module('MyServiceModuleOne', ['MyServiceModuleTwo']); Then inject notifytwo into notify: myModule.factory('notify', function(notifytwo) { return { sampleFun: function() { notifytwo.sampleFunTwo(); } }; }); myModuleTwo.factory('notifytwo', function() { return { sampleFunTwo: function() { alert('From notify two'); } }; }); And the code on plunker

Categories : Javascript

Exchanging module values in AngularJS test
You can use $provide.value('name', 'Bob'); to inject the value. var myApp = angular.module('myApp', []); myApp.factory('greet', function (name) { return function () { return 'Hi ' + name + '!'; } }); myApp.value('name', 'example'); describe('myApp', function () { beforeEach(angular.mock.module('myApp')); it('should say "Bob"', function () { module(function ($provide) { $provide.value('name', 'Bob'); }); angular.mock.inject(function ($injector) { var greet = $injector.get('greet'); expect(greet()).toBe('Hi Bob!'); }) }); it('should say "Bar"', function () { module(function ($provide) { $provide.value('name', 'Bar'); }); angular.mock.inject(function ($

Categories : Javascript

Uncaught Error: No module: users Angularjs
You have syntax errors with the following return $resource "users/:id", { id: '@id' }, { ... } Should be return $resource("users/:id", { id: '@id' }, { ... });

Categories : Ruby On Rails

Axis2 web-service in a multi module maven project
Axis2 is JAX-WS compliant, therefore you can use the wsimport tool instead of wsdl2java. I assume you've taken the contract first approach and you are generating the stubs from the WSDL file. Here is the doc to the wsimport maven plugin. A lot of things can be changed (destDir for instance). Maven clean deletes the generated source folder. I will have to protect the stub with the implemented business logic from deletion. You can actually generate the stubs to your regular package structure (perhaps to its own package) and add include (or exclude) the generated files in the maven clean plugin configuration. If you use this mvn plugin, your IDE should add the generated files to the project classpath. If I were you, I would definitely try to do as much as possible as JAX-WS compliant, bec

Categories : Java

starting an android native service with titanium module
The problem was in the way I was setting intent.. instead of: backOverlayService = new Intent(); backOverlayService.setClassName("com.eliddell.testservice", "ForegroundService.class"); I use: backOverlayService = new Intent(TiApplication.getAppCurrentActivity(), ForegroundService.class);

Categories : Android

How can I test angularjs controllers that have been created with module().controller?
You test them the same exact way. Make sure you're loading the module with the controller in your tests via the module function in the ngMock module. Something like this: beforeEach(module('testAngularApp'));

Categories : Javascript

Setting templateUrl in an AngularJS Module to increase modularity
If you're using Grunt, this is easy. Not because modularizing AngularJS is trivial, but because all the hard work has already been done for you by the good folk doing angular-bootstrap... When I faced this problem I simply downloaded their Gruntfile and changed every ui.bootstrap to my-angular-module. Since I mimicked their basic directory structure, it worked right out of the box. Also, you might want to update the Angular and Bootstrap versions. E.g., change ngversion: '1.0.8', bsversion: '2.3.1', to ngversion: '1.2.3', bsversion: '3.0.2',

Categories : Angularjs

AngularJS - How to use $routeProvider and custom module in config function?
As I commented you can create a provider instead of a factory and put the URLs in that as the central place: angular.module('urls', []). provider('urls', function (){ this.$get = function(){ var obj = {} obj.login = function(){ return '/login';} //more urls here, you don't really need function though return obj; } }); angular.module('app', ['urls']). config(function ($routeProvider, urlsProvider) { $routeProvider. when(urlsProvider.login(), { controller: PageCtrl, templateUrl: 'tem.html' }). otherwise({ redirectTo: urlsProvider.login() }); }); However, you can not inject the $location service to the urls

Categories : Javascript

Can i directly access module constant from HTML under AngularJS
IMHO the better way to do this is use the $rootScope In html every scope inherits from the $rootScope, so if a variable isn't present in the current scope angular use the one declared in $rootScope. A good (IMHO) way is to initialize this in the run "phase" angular.module('myApp') .run(function ($rootScope) { $rootScope.ROUTES = ROUTES });  

Categories : Angularjs

How to move my Asynchronous Facebook SDK script to service/factory module?
I would build a factory that returns a promise that's resolved when the SDK is loaded. Something like: (function (window) { "use strict"; var angular = window.angular; angular.module('facebookService', []).factory('FacebookService', [ '$q','$rootScope', function ($q, $rootScope) { function init() { $rootScope.$apply(function () { defer.resolve(); }); } var defer = $q.defer(); defer.promise.then(function () { // FB.Init... window.FB = 'Facebook SDK loaded'; // Remove this line }); window.fbAsyncInit = angular.bind(this, init); return defer; }]); }(window)); Now you can just inject the sevice and append method on the pomise using FacebookSer

Categories : Angularjs

Can I compress Web Service Request and response using mod_gzip module of apache?
The server can compress the response, if the client stated in its request that it can deal with compressed responses (e.g. the client sends Accept-Encoding: gzip, deflate in its request). The server cannot compress the request, that's pointless. The client will have to compress the request before it sends it to the server; but the client cannot know whether the server can handle a compressed request, so typical browser clients do not do so. If you have an API which serves specific clients, the client can compress the request and the server can decompress it simply by agreement. mod_deflate can be configured to compress and decompress both ways. Also see http://serverfault.com/questions/56700/is-it-possible-to-enable-http-compression-for-requests.

Categories : PHP

AngularJS : File concatenation breaks module declaration order
If you split a module in multiples js files and you don't want to manage manually in which order your build should concatenate files then you will need RequireJS. Personally, I try to avoid splitting a module in several files for several reasons : It can be hard to find all controllers/services/etc.. from a single module If the module is becoming too big, then it probably means you should split in several modules It's cumbersome enough to have to declare manually a list of modules dependencies and a list of injected dependencies for each module. Add to that a list of js dependency files needed by RequireJS and you will spend most of your time declaring boring stuff instead of resolving business problems However, if you keep the 1 module / 1 file rule, you'll see your index.html growin

Categories : Angularjs

Unit testing directives without unnecessary dependencies in module AngularJS
You have to mock them. For example, you can create a module called mocks with a d with the services or directives you want to mock. You then load it with beforeEach(module('mocks')); and your calls from the test suite to whatever service you have in mocks will be using the dummy implementation. You can put this mock module in your test folder, like /test/lib/my-mocks.js (next to angular-mocks.js, if you're using angular-seed). Lastly, you include it in karma.conf.js: files = [ 'app/lib/jquery/jquery-1.9.1.js', JASMINE, JASMINE_ADAPTER, 'test/lib/jasmine-jquery.js', 'app/lib/angular/angular.js', ... 'test/lib/myproject/my-mocks.js', ... ]; Another approach is using jasmine spies. For example: spyOn($location, 'absUrl').andCallFake(function (p) { return 'http://lo

Categories : Angularjs

ImportError: No module named gdata.youtube.service in Django windows 7
Looks like you are missing the dependencies library: gdata python library Documentation here: https://github.com/laplacesdemon/django-youtube#dependencies And here is documentation on how to install python libraries http://docs.python.org/2/install/#installing-python-modules

Categories : Django

AngularJS Service for XHR
I think it may relate to API endpoint issue of Reddit.com. If you try this API, it will work using jsonp var url = "http://www.reddit.com/top.json?jsonp=JSON_CALLBACK"; For the API /.json, I suggest you implement the server side code to retrieve data though it returns valid JSON but somehow can't be accessed correctly across domain.

Categories : Javascript

Using JSON as a service in AngularJS
you could try this : the app.js: angular.module('HomeCourtArenaApp', ['HomeCourtArenaApp.services', 'HomeCourtArenaApp.controllers']). config(['$routeProvider', ($routeProvider) { $routeProvider.when('/', { templateUrl: 'views/main.html', controller: 'MainCtrl' }); $routeProvider.otherwise({ redirectTo: '/'}); }]); angular.module('HomeCourtArenaApp.services', ['ngResource']). factory('JsonData', function($resource){ return $resource('data/shoe3Dconfig.js'); }); angular.module('HomeCourtArenaApp.controllers', []). controller('MainCtrl', ['$scope', 'JsonData', function($scope, JsonData) { $scope.objs = JsonData.query(); console.log(objs); } }]); and this is not necessary to load the datas in the html <script src="scripts/services/data.j

Categories : Angularjs



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.