w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Angularjs - Populate select box using ng-options
You can use <div ng-repeat="(key, value) in keywords"> <select ng-options="item for item in value" ng-init="index = getRandomIndex(value)" ng-model="value[index]">{{item}}</select> </div> together with a function to get the random index for current array $scope.getRandomIndex = function(item){ var index = Math.floor((item.length * Math.random())); return index; } DEMO

Categories : Angularjs

How to do an HTTP Options request in AngularJS?
$http supports options. Options doesn't have a function declared like $http.get() or $http.post(), but you can specify any method you want by specifying the method and passing it directly into $http. $http({method: 'OPTIONS', url: '/foo'})

Categories : Http

Using ng-options within a directive and getting options data from injected service
In my opinion, you have several options (as pointed out in the comments): 1. create controller for the directive In you directive's template, use a controller, i.e. <div ng-controller="SelectController"> <!-- your select with the ngOptions --> </div> and create the SelectController as a regular controller: var app = angular.module("app.controllers", []) app.controller("SelectController", ['$scope', 'myDataService', function(scope, service) { scope.options = service.whatEverYourServiceDoesToProvideThis() }]); You can also give your directive a controller, which works just the same: recManagerApp.directive(myDirective, function () { return { restrict: 'E', templateUrl: '/templates/directives/mydirective.html', scope: { m

Categories : Angularjs

AngularJS Client, JAX-RS Jersey Rest Service - application/json client request throwing 'Error parsing media type'
Your Content-Type header is invalid (see spec 14.17 Content-Type). Based on you JAX-RS resource you should use application/json as Content-Type (without application/x-www-form-urlencoded): $http({ method: 'POST', data: $scope.Patient, url:'/ManagePatient/AddPatient', headers: {'Content-Type':'application/json'} }); EDIT 1: If you want to see requests that are coming to your server you can register LoggingFilter and it will show you some useful information. You can turn it on in: web.xml (add it to the JAX-RS servlet definition): <init-param> <param-name>jersey.config.server.provider.classnames</param-name> <param-value>org.glassfish.jersey.filter.LoggingFilter</param-value> </init-param> Application extension: public class MyAppl

Categories : Angularjs

Search using VBscript and populate Options dynamically
It seems like you really only care about whether or not the regex matches in a particular line or not. Since you don't need to know how many matches occurred, nor do you need the actual match text, you can use the Test method instead. This should be faster because it will stop after the first match, plus it doesn't have to construct the Matches collection. I'd also leave the Global property at its default value of False for pretty much the same reason, but if you're just using the Test method, I don't think the Global property matters.

Categories : Search

How to dynamically generate jQuery to populate options for a
I'm still unsure about why you don't just populate the select box with server-side code, but you might need to defer your script execution until the DOM has been loaded. Can you try this: string JSCMD = "$(function(){"; JSCMD += "$('#grouplist2').empty();"; foreach (ListItem li in GroupList.Items) { if (li.Selected) { JSCMD += "$('#groupList2').append('<option value=" + li.Value + ">" + li.Text + "</option>');});"; } }

Categories : C#

Who's responsibility is it to populate Zend_Form's options with database values?
The drawback of having forms aware of the database is that you will get tightly coupled components - Zend_Form and your database access layer in the case above - while these 2 must not have anything in common. Imagine possible scenarios: You move your data from one database to another. Or you want to add a caching layer on the top of it. You will have to modify db specific calls throughout your project. You decide to unit test your class. You will need to maintain the db connection in tests (or a mock for it). You want to use the same form class in another place and have select stuffed with options not from the database but from ini config file... well, you got the idea. So the best solution would be having some db-specific mapper class which can get you data you want. And then pass

Categories : PHP

How to Populate WPF Datagrid by using WCF Service
Here is some code I hope you will find useful: namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); FillDataGrid(); } private void FillDataGrid() { Service1Client client = new Service1Client(); client.GetAllEmpCompleted += new EventHandler<GetAllEmpCompletedEventArgs>(client_GetAllEmpCompleted); client.GetAllEmpAsync(); } void client_GetAllEmpCompleted(object sender, GetAllEmpCompletedEventArgs e) { GridTest.ItemsSource = e.Result; } } } Source: https://chandradev819.wordpress.com/2010/09/21/easiest-way-to-consume-wcf-service-and-fill-datagrid-from-database-in-silverlight/

Categories : C#

Facebook Request.callback() not firing when request is made from Service
The problem, as you have probably noticed, is that the executeAsync() method needs to be called from a UI thread for the callback to work. A service, on the other hand, runs in the background, thus with no access to the UI thread. Since I don't think you are planning to do any UI work in your onComplete(), one suggestion is to use a different API that does not require running on UI thread. One such API is executeAndWait(), which will return a response object you can use for checking against errors. For example: Response resp = uploadPhoto.executeAndWait(); if(resp.getError() == null){ //Success }

Categories : Android

Second request recives the first one that was still processing
It looks to me as though you're using a global/window variable for xmlhttp. If this is the case, certain parts of the second call will overwrite the first. Consider using an Object Oriented approach, or otherwise instantiating these as vars in different scopes.

Categories : Javascript

AngularJs chaining an undefined ajax request and output progress (also if one request fail)
You can use $q.all to get all response and then process the response at the same time $q.all(promises).then(function (values) { //process all result together }); And you can also plugin a callback function to each promises to indicate the progress $q.all(promises[0].then(callback), promises[1].then(callback), ...).then(function (values) { //process all result together });

Categories : Angularjs

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

Processing user request in a separate activity
Start up an Activity for result, with startActivityForResult() Like this, you can have the started activity do your stuff, and return a value. http://developer.android.com/training/basics/intents/result.html

Categories : Android

Processing request URLs from browser by the .NET Framework
If you host your application in IIS, then when a request comes-in, then this request is initially intercepted by IIS. Let's suppose that you hosted your application in a virtual directory called /myapp. When a request comes by starting with /myapp then IIS will handle the execution of the request to the corresponding ASP.NET pipeline. The ASP.NET pipeline will then parse the incoming request and search for corresponding managed handlers that can serve the request. If a managed handler is found that can serve the request then the processing will be passed to this handler. In the case of as ASP.NET MVC application that will be the MvcHandler which will then take care of routing and dispatching to the appropriate controller and action to serve the request.

Categories : Asp Net

How to organize concurrent request processing in Scala?
If you must have def process(req: Request): Response), then I think your Scala solution may turn out to be similar to Java. If you can have def process(req: Request): Future[Response], the it opens other possibilities. When using futures, you provide (implicitly or explicitly) an execution context that can be constructed from a Java executor. So you would be able to choose your thread pool size and queue size that way. The benefit of using futures is that you can compose them with map and flatMap and a few other combinators. See http://docs.scala-lang.org/overviews/core/futures.html for more information. With actors, you have another model of concurrency where you can create K actors. You can have a router that dispatches each request to the actors. Each actor is independently processes

Categories : Scala

Nuget 2.7: "an error occurred while processing this request"
I too am having the same issue with Nuget 2.7. As a workaround I am currently utilizing the Package Manager Console. The command Get-Package -updates will list all available updates for a project: From there you can use the Update-Package cmdlet to update specific packages.

Categories : Visual Studio 2010

Populate dropdown using curly braces + angularjs
You certainly can populate a dropdownlist using the curly braces in angular, but it won't have the expected effect. If you want to have the data-binding in your select box, you should use the select directive which writes the option tags in a similar way the ng-repeat directive would. Here's an example: js: $scope.selectables = [ { label: 'A', value: 1}, { label:'B', value: 2}, { label: 'C', value: 3} ]; // this is the model that's used for the data binding in the select directive // the default selected item $scope.selectedItem = $scope.selectables[0]; html: <select ng-model="selectedItem" ng-options="o.label for o in selectables"> </select> <p>Selected item value: {{selectedItem.value}}</p> Here's a demo to clear things up: http://

Categories : Javascript

Populate AngularJS model with existing values
The big issue here really is that in your current setup, jQuery is operating outside of the angular world. It has no concept of angular scopes, or any real way of accessing them without being a little bit hacky and going against how angular works, BUT you can do this if you want. After you've loaded your data from jQuery, rather than setting the values of your form, you can just set the values directly within the angular models. If for example you had your page something like <div class="wrapper" ng-controller="UserCtrl"> <form> ... inputs as in your post ... </form> </div> Then inside your controller, put $scope.user = { firstName: "", lastName: "" } Then you're actually able to get the angular scope from jQuery at any point. In this

Categories : Angularjs

Angularjs: ng-options
It is model driven, you need to set $scope.clientList to the client id. In your controller you can do something like this function Ctrl($scope) { $scope.clients = [{ id: 1, clientName: 'Joe' }, { id: 2, clientName: 'Tom' }, { id: 3, clientName: 'Bob' }]; $scope.clientList = 2; //clientList is the model defined in the select directive } Demo on jsFiddle And if the id field is a string, you should set clientList as string rather than integer: $scope.clientList = "245";

Categories : Angularjs

WCF Service Slow - Options?
Enable tracing with switch value All. It should reveal something helpful. <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="All" > <listeners> <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:UserTraces.svclog" /> </listeners> </source> </sources> <trace autoflush="true" /> </system.diagnostics>

Categories : Json

What are the best practices on processing HTTP responds from WCF RESTful service?
The output is available in two forms JSON and XML, and handling error would depend on how it is being structred in the response. you make like to have a look at this.

Categories : C#

REST web service: which HTTP method to have server to do some processing
Of course you can do this. In this case, the resource is the method (the method is a resource also, because you can do some processing, return a message or other entity, so it doesn't matter what kind of processing it is about). String is a valid response entity (JAX-RS Response Entity Types). You may be interested in subresource method locators: http://docs.oracle.com/javaee/6/tutorial/doc/gknav.html#gklag .

Categories : Java

Stop processing Flask route if request aborted
As far as I know you can't know if a connection was closed by the client during the execution because the server is not testing if the connection is open during the execution. I know that you can create your custom request_handler in your Flask application for detecting if after the request is processed the connection was "dropped". For example: from flask import Flask from time import sleep from werkzeug.serving import WSGIRequestHandler app = Flask(__name__) class CustomRequestHandler(WSGIRequestHandler): def connection_dropped(self, error, environ=None): print 'dropped, but it is called at the end of the execution :(' @app.route("/") def hello(): for i in xrange(3): print i sleep(1) return "Hello World!" if __name__ == "__main__": app.ru

Categories : Python

How to do a request to the server and liberate JavaScript to continue processing
Use jQuery's ajax() function instead of rolling your own AJAX solution. ajax() defaults to asynchronous requests, so you can pass it a function that is called on request completion: $.ajax({ type: "POST", url: "../getFdList?Fds=allFds" }).done(function( msg ) { alert( "Response: " + msg ); }); That way, you can call ajax(), give it your callback function, and carry on with whatever other processing you need to do. Another plus for jQuery is that it's pretty well cross-browser without any effort.

Categories : Javascript

Angularjs: ng-options with group
The grouping doesn't quite work like that, if you change your json to something like this: [ {"ID":"1", "TIPIS":"GroupName1", "DESC":"name"}, {"ID":"2", "TIPIS":"GroupName1", "DESC":"name1"}, {"ID":"3", "TIPIS":"GroupName2", "DESC":"name2"}, {"ID":"4", "TIPIS":"GroupName1", "DESC":"name3"}, ] Then you'll get the grouping the way you want jsFiddle: http://jsfiddle.net/rtCP3/182/

Categories : Angularjs

!! Unexpected error while processing request: failed to allocate memory
Try something like this: File.open(fileName) do |csv| csv.each_line do |line| CSV.parse(line) do |values| # Here you can do your manipulation end end end This way is slower, but it should ensure you don't get out of memory.

Categories : Ruby On Rails

Browser tries to save JSON response to AJAX request instead of processing it
As you can see in the dialog, the file type is "Unknown File Type". In your code, I can see that you set the content type: response.setContentType( "application/json" ); and you're doing this before you start to write the data of the response. At first glance, this should work but somehow, the call to setContentType has no effect. Go to the debug tools of your browser and look into the response headers. You can find a line Content Type in there which should look like this: Content-Type: application/json If that line is missing, set a break point in the line with response.setContentType() and look into the response. There should be a stream in there. Make sure that stream is still empty.

Categories : Java

What is the direct cause and source of the "Sorry, an error occurred while processing your request." message?
The default error handling of an out-of-box ASP.Net MVC Application redirects errors to the Error.aspx shared view. You will find the "Sorry, an error occurred while processing your request" message text inside the Error.aspx file. The message is not generated from a .Net class. The following SO question brought me to the light: ASP.NET MVC HandleError not working (customErrors is set to "On") To see more details about the underlying error you have a few options. Customize the default Error.aspx page to display details about the underlying error. Turn off the CustomErrors in the web.config file. Future errors should display the default ASP.Net "yellow screen" error details instead of the "Sorry, an error occurred message". Handle the error specifically in the associated Actio

Categories : Asp Net Mvc

How add options to a select with an AngularJS directive?
You can use directive from Angular JS: Markup: <div ng-controller="MainCtrl"> <select ng-model="country" ng-options="c.name for c in countries"></select> {{country}} </div> Script: app.controller('MainCtrl', function($scope) { $scope.countries = [ {name:'Vereinigte Arabische Emirate', value:'AE'}, {name:'Andorra', value:'AD'}, ]; $scope.country = $scope.countries[1]; }); Check the docs of select: Angular Select EDIT WITH DIRECTIVE Directive: app.directive('sel', function () { return { template: '<select ng-model="selectedValue" ng-options="c.name for c in countries"></select>', restrict: 'E', scope: { selectedValue: '=' }, link: function (scope, elem, attrs) {

Categories : Javascript

AngularJS and ng-options from resource default value
I encountered the same problem myself, and I believe that's the best way to go about it. That's also the way it's done in their documentation for the ng-options directive.

Categories : Angularjs

AngularJS selecting multiple options
ngModel is pretty awesome! If you specify the indexes as a model selectedValues <select multiple ng-model="selectedValues"> built from your list (selected) in a $watch $scope.$watch('selected', function(nowSelected){ // reset to nothing, could use `splice` to preserve non-angular references $scope.selectedValues = []; if( ! nowSelected ){ // sometimes selected is null or undefined return; } // here's the magic angular.forEach(nowSelected, function(val){ $scope.selectedValues.push( val.id.toString() ); }); }); ngModel will automatically select them for you. Note that this data binding is one-way (selected to UI). If you're wanting to use the <select> UI to build your list, I'd suggest refactoring the data (or using ano

Categories : Javascript

AngularJS inner ng-repeat not processing $index.$parent in function argument
First let me point out that ng-repeat creates new scope. Also, I'm assuming that the outer repeat does not sit inside yet another repeat. Assuming that, notice in your first example that you pass $index to the selectedNodeAtLevel function. This works because $index is defined by the outer repeat and parsed in the context of the scope of the outer repeat. This $index variable corresponds to each nodeName. So the second example fails because there is no $index defined in the outer repeat's $parent (which actually refers to the scope of the controller this code sits in). In at least the second case, it seems that you expect that $index refers to the inner repeat, but it does not, it refers to the $index defined in the already defined scope. So you should have issues even in your first ex

Categories : Angularjs

Missing options request using ember-data
You could try this two changes: App.Store = DS.Store.extend({ revision: 13, adapter: DS.RESTAdapter.create({ url: 'http://clara.eagle/v1/money', corsWithCredentials: true }) }); And additionally add this to your server configuration Access-Control-Allow-Credentials: true this goes in conjunction with the corsWithCredentials option for the ajax setup: Access-Control-Allow-Origin: http://ember.eagle Access-Control-Allow-Headers: X-Requested-With, X-AUTHENTICATION, X-IP Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Hope it helps.

Categories : Ember Js

What are my options in ServiceStack to assign a unique ID to each request?
Using a global request filter would work, you can do something like: public class IRequiresUniqueId { public Guid UniqueId { get; set; } } And then mark all request DTOs you would like to have a Unique Id by implementing the above interface: public MyRequest : IRequiresUniqueId { public Guid UniqueId { get; set; } } Then you can use a Global Request Filter to set all request DTOs that have them: this.RequestFilters.Add((httpReq, httpResp, requestDto) => { var requiresUniqueId = requestDto as IRequiresUniqueId; requiresUniqueId.UniqueId = Guid.NewGuid(); });

Categories : Api

Pre-flight OPTIONS request failing over HTTPS
I'm assuming this is an issue with the preflight request. There are two types of CORS requests: simple, and not-so-simple. The simple kind is either a GET or POST with no custom headers whose content type is "text/plain". The not-so-simple kind is any request using custom headers, utilising request methods other than POST or GET, and using different content body types. These requests will be "preflighted"; that is the browser will make a preflight request on the clients behalf in order to determine whether or not the server will allow this request. The preflight request uses the OPTIONS method. I'm willing to bet if you use something like Firebug to have a look what's going on you'll see something like this in the Net tab: "OPTIONS activity" with a status of "Aborted". Unfortunately the

Categories : Ajax

dynamic provider options through app config AngularJS
I had the same problem recently. I couldn't find a solution to work within the bounds of the framework so I worked around the problem by manually bootstrapping angular after I have loaded all of the client configuration information. http://docs.angularjs.org/api/angular.bootstrap $.get('/api/context', function () { // ... angular.bootstrap($('#container'), ['app']); });

Categories : Javascript

Angularjs - $resource causing a 404 - method: OPTIONS
The answer here is that your browser is running into a cross domain issue See http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/ for an explanation and Jquery: Why am I getting an OPTIONS request insted of a GET request? for a question basically the same as yours.

Categories : Angularjs

angularjs: change filter options dynamically
You can define ng-model like: ng-model="search[filter]" to change dynamically to which variable it should be binded (where filter is another $scope variable). See the fiddle: http://jsfiddle.net/lopisan/vzQKk/1/ You have to add this line to the controller: $scope.search = {name:'', phone:'', $:''}; And change input: <input type="text" ng-model="search[filter]">

Categories : Javascript



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