w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
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

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

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

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 - 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 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 - $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

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: 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

how can I use functions as well as variables in the expression for ng-options in Angularjs
Rather than using a function in ng-options try this; In your first select box use ng-change directive like this; <select ng-options="user.id as user.description for user in firstSelect" ng-model="firstSelectBox" ng-change="change();"></select> In your controller; $scope.firstSelect=[{values of first select box}] $scope.change = function(){ $value = $scope.firstSelectBox; $http.get('API url').success(function (data) { $scope.secondSelect = data; }); } Change your second select box as; <select ng-options="user.id as user.description for user in secondSelect" ng-model="secondSelectBox"></select> Hope it helps.

Categories : Javascript

Use Filter To Search In Options add a null option in angularJS
AngularJS will indeed add a dummy option if ng-model is set to a value that is not in ng-options. I am not aware of a way to prevent this when the filter doesn't return any values (when ng-options is empty, ng-model can never be in it), but when it does, you could set ng-model to the first item, which means the dummy option will not be created. You could use ng-change or similar to do this.

Categories : Angularjs

Loading select options from remote site using angularjs
You should use the ng-options directive. Example: <select ng-model="selectedClient" ng-options="client.name for client in Clients"> Here is more info. The usage of ng-options is a bit different for arrays vs objects and there are a few different ways to use it, but there's a little somethin' for everyone: http://docs.angularjs.org/api/ng.directive:select

Categories : Angularjs

Nested checkboxes in AngularJS resource with external options
Update Ignore my answer, misread you nesting request. If anyone needs nesting guidance see below: The best way to nest in angular that I have found is to create a template which is aware of child items like this: <script type="text/ng-template" id="tree_item_renderer.html"> <span>{{tag.Name}}</span> <ul ng-show="tag.Children.length > 0"> <li ng-repeat="tag in tag.Children" ng-include="'tree_item_renderer.html'" ></li> </ul> </script> <ul class="tag-list"> <li ng-repeat="tag in tags" ng-include="'tree_item_renderer.html'" ></li> </ul>

Categories : Angularjs

AngularJs and
Angular overrides the "selected" property when you bind the select to a model. If you inspect the rendered DOM you will find that a new item has been added: <option value="? undefined:undefined ?"></option> In order to automatically select the third option you need to pre-populate the model in scope. There are a few ways to do this, including wrapping the select in a controller: <div ng-controller="MyCtrl"> <select id="myselection" ng-model="selectedColors"> <option value="1">Red</option> <option value="2">Blue</option> <option value="3">Green</option> </select> <div>Selected Colors: {{selectedColors }}</div> And then defining that model in the controller. var myApp = angula

Categories : Angularjs

Angularjs Select option with multiple static options
I would try following: <div ng-init="arr = [{name:'A', val:1},{name:'B', val:2},{name:'C', val:2}]"> <select ng-model="v"> <option ng-repeat="o in arr" value="o.val">{{ o.name }}</option> <option>Other</option> </select> <input type="number" ng-model="otherval" ng-show="v == 'other'"/> </div> or, <div ng-init="arr = [{name:'A', val:1},{name:'B', val:2},{name:'C', val:2}]"> <select ng-model="v" ng-options="o.val as o.name for o in arr.concat([{name:'Other',val:'other'}])"> </select> <input type="number" ng-model="otherval" ng-show="v == 'other'"/> </div>

Categories : Angularjs

AngularJS Select/Options scope breaking calculator
I've made a few changes to your code and it now works. (still couldn't get it to work in jsFiddle for some reason, but I've never liked it much anyway) There were many problems. It was a combination of your HTML having issues as well as your Angular Controller and other things being improperly formatted. First of all your Javascript had lots of issues. I declared several of your variables as var because there was no declaration whatsoever. Also a couple of your variables were not declared on the scope, so they were not able to be bound to the html. On top of that, there were some major issues in your HTML, such as a random ending </select> tag and multiple divs which did not have end tags. So I've updated all your code and the select now works See updated code below: HTML: <!D

Categories : Javascript

AngularJS: Updating ngModel property when select options change
I'm not sure the exact behaviour that you want, but you can always watch options and, therefore, on change take an action (JSFiddle): function bodyCtrl($scope) { $scope.selection = 0; $scope.options = [ 10, 20, 30]; $scope.changeOptions = function() { $scope.options = [11, 22, 33]; }; $scope.$watch('options', function() { $scope.selection = 0; }); } Hope this helps.

Categories : Javascript

how to pass parameters to Handlebars helper? What's the difference between options.hash & options.data
Parameters passed to a helper become arguments to the helper function. The values you provide in the template immediately after the {{helperName become the arguments. The last argument passed to the helper is an options object that provides additional information to helper like, an options.hash and options.contexts, etc. Key value pairs provided after the parameters correspond to the options.hash property. For a hello helper that takes 3 arguments, the helper would be, Ember.Handlebars.helper('hello', function(a, b, c, options) { return '%@ - %@ - %@'.fmt(a, b, c); }); The hello helper can be used in a template like so, {{hello lorem ipsum dolor}} Here the values of lorem, ipsum, and dolor properties would be used and returned as a combined string. In addition to the required ar

Categories : Ember Js

Disabling/Removing Select Options created via a Knockout options binding
Not sure if I understand correctly, but it sounds like you're looking for Computed Observables: self.AvailableItemTypes = ko.computed(function() { var selectedTypeIds = this.SelectedItemTypes().map(function(el) { return el.Id; }); return this.ItemTypes().filter(function(el) { return selectedTypeIds.indexOf(el.Id) === -1; }); });

Categories : Knockout Js

JComboBox in JTable not displaying options, only the correct number of blank options
After the first while loop navigates across the ResultSet rs the subsequent while loop is never entered as there as no more available records and rs.next() returns false while (rs.next()) { items[count] = rs.getString("parts"); ... } Rather than determine the size of the String array items using a separate loop, use an Vector<String> to build a collection of Strings. This can then be passed directly to the JComboBox constructor after a single navigation of the ResultSet. Vector<String> data = new Vector<>(); while (rs.next()) { data.add(rs.getString("parts")); } count = data.size(); JComboBox<String> jcb = new JComboBox<>(data); As a bonus the count variable equates to data.size()

Categories : Java

Allowed Options in NSJSONSerialization class method dataWithJSONObject:options:error
NSJSONWritingPrettyPrinted is the only option supported at this time. You can provide 0, of course, if you don't want pretty printing. You can find a discussion of it at the bottom of this page. kNilOptions equates to 0, but it's included as part of the Carbon APIs, not Cocoa.

Categories : Objective C

html select control click not showing options list until mouse is hovered towards the options
it seems IE9 is blocking javascript...i hope this helps http://answers.microsoft.com/en-us/ie/forum/ie9-windows_vista/internet-explorer-9-drop-down-menus-do-not-pull-up/954c5c71-5878-40a4-b9f8-68991922e85a

Categories : Javascript

Excel: Display value from list of options if numbers begin with value from options
VLOOKUP() I believe is the right function for this. Assuming that you want the area names in column E in Sheet1 as from row 2, the phone numbers are in columnB of that same sheet and the table with prefix and area code in Sheet2 columns A and B, you can use: =VLOOKUP(LEFT(B2,5), Sheet2!A:B, 2, FALSE) LEFT(B2,5) extracts the first 5 characters from the phone number stored in B2. If there are area codes of different lengths, then the formula will have to be revised and it will be much more complex. Sheet2!A:B is the table to lookup the data 2 is the index of the column containing the values you want to get (the first index is the column containing the area codes) FALSE means exact match. I don't think you'd like to get the area code immediately smaller than the one you're looking for,

Categories : Excel

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

Default state (Add options) overrides my update options?
If this is a plugin, you need to set the option for the first time with register_activation_hook. If a theme, use after_setup_theme. There's an alternative technique for run_once described in this WPSE Answer that works quite well too. Here's a working example loosely based on yours and some Codex samples using run_once. Note the use of the function checked(). add_action('admin_init', function() { // Change the "init_*" to anything else to `run_once` again if ( wpse_25643_run_once('init_checkbox_default') ) { add_option('my_checkbox_default', true ); } register_setting('media','my_checkbox_default'); add_settings_field( 'my_checkbox_default', 'Checkbox:', 'my_default_checkbox_settings_function', 'media' ); }); funct

Categories : PHP

Show options of selected options inside the same
If you are looking for a tree view layout using jquery, try this code: $('.tree li').each(function(){ if($(this).children('ul').length > 0){ $(this).addClass('parent'); } }); $('.tree li.parent > a').click(function(){ $(this).parent().toggleClass('active'); $(this).parent().children('ul').slideToggle('fast'); }); Demo and Source: http://www.webstutorial.com/jquery-treeview-list/jquery

Categories : Jquery

GCC compiler options: which set of enabled options is correct?
From GCC documentation: --help={class|[^]qualifier}[,...] Print (on the standard output) a description of the command-line options understood by the compiler that fit into all specified classes and qualifiers. whereas If the -Q option appears on the command line before the --help= option, then the descriptive text displayed by --help= is changed. Instead of describing the displayed options, an indication is given as to whether the option is enabled, disabled or set to a specific value (assuming that the compiler knows this at the point where the --help= option is used) It appears that --help simply shows which options one can enable, while -Q allows one to see if it is actually enabled. Also: The output is sensitive to the effects of previous command-line op

Categories : C

Why Can't I have multiple ng-if options in a select when using ng-options
Basically for 2 options with ng-if = true, the code actually is equivalent to <option value=""> Please Select an Approver Type: </option> <option value=""> Please Select One: </option> Since ngOptions accepts only a single hardcoded option, Optionally, a single hard-coded element, with the value set to an empty string, can be nested into the element. This element will then represent null or "not selected" option. the 1st one will be overwritten.

Categories : Javascript

Options with Options with Python argparse?
In general, I think what you want is impossible because you cannot associate the optional parameter values together. That is, I can't see how to associate --param 12 with --aligner aligner1. However. You can use argparse as follows: p = argparse.ArgumentParser () p.add_argument ("--aligner", action="append", nargs="+") This will create multiple aligner arguments, each requiring at least one argument (the aligner name). You then can use an additional encoding scheme (that you can document in the help text for the parser) which encodes the parameters for each aligner. For example, you could call your script with: ./script.py --aligner aligner1 param=12 --aligner aligner2 param=30 other_param=28 You then split out the additional arguments for each aligner into a list, split by '=' and

Categories : Python

Show Download file Dialog with Ionic Zip Extract
We too have faced this particular problem, our issue was that we have number of files to zip and after zip it size comes to somewhere around 2GB's. How we sorted out. 1. We have a link to download 2. User clicks on it 3. We show a popup having progress wheel 4. We process Zip in background in different thread. (Zip have to be created exclusively for this user only) 5. Once everything is fine, we show a user a download link 6. User download it at any place he wants. I am not sure if this can help you or not, however it works for us. Edited to add some code: We have achieved this using JQuery // Action for download zip link $(".downloadZip").click(function () { var jqXhr; $("a.downloadZipAction").attr("href", "/GetFile?fileName=yourfile.Zip");

Categories : C#

Rails 4 search options. What options are available to combine a full HTML site search with an ActiveRecord search?
To rephrase your question, you want to combine results of Google Site Search with custom search results provided by Sphinx, Solr or Elasticsearch? First, you cannot really customize the content of Google Site Search results easily. You can customize the design, and could employ some JavaScript tricks to "merge" its results with another data source, but I'd say the approach is not something maintainable and, more importantly, usable. Notice, that you can display the search results from Elasticsearch with Tire in the same way as ActiveRecord instances, all the usual Rails helpers such as url_for etc. work. The easiest way to evaluate the integration is to generate the example application with the Rails template. If you want to combine the results from ActiveRecord data and the results fr

Categories : Ruby On Rails

jquery TypeError: state is undefined var options = state.options;
<div> <a href="#" id="toggle3">Slide Toggle3</a><br /><br /> <a href="#" id="toggle4">Slide Toggle4</a><br /><br /> <div class="toggle" style="display:none; background-color:#4CF;width:100px;height:200px;"></div> </div> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type="text/javascript"> $(function () { $('#toggle4').click(function () { $('.toggle').hide('1000'); $('.toggle').text('toggle 4 clicked'); $('.toggle').slideToggle('1000'); return false; }); }); $(function () { $('#toggle3').click(function () { $('.toggle').hide('1000'); $('.toggle').text('toggle 3 cl

Categories : Javascript

How to get all options of jquery datepicker to instanciate new datepicker with same options?
You can get the options of the existing datepicker using this: var options = jquery('#datepicker').datepicker('option', 'all'); to get one specific option, for example the numberOfMonths: var numberOfMonths = jquery('#datepicker').datepicker('option', 'numberOfMonths');

Categories : Javascript

Feed select options from DB depending on another select options
Just use ajax for this, when one select change fetch data from the server to feed other select. <select class="select_one"> <?php /* render first select ?> </select> <select class="select_two"></select> <script> $(function() { $('.select_one').change(function() { var select = $('.select_two').empty(); $.get('script.php', {region: $(this).val()}, function(result) { $.each(result, function(i, item) { $('<option value="' + item.value + '">' + item.name + '</option>'). appendTo(select); }); }); }); }); </script> and you script.php should return JSON from db: if (isset($_GET['region'])) { $sql = new mysqli('localhost','username','password','database

Categories : PHP

AngularJS - Close tile and load new view from model in ngRepeat directive AngularJS
Fix this bug: In directive linker: var linker = function (scope, element, attrs) { var loader = getTemplate(scope.content.Type); loader.success(function (html) { element.html(html); $compile(element.contents())(scope); });

Categories : Javascript

AngularJS: Protecting routes with angularjs depending if the user is authorized?
Using resolves should help you out here: (code not tested) angular.module('app' []).config(function($routeProvider){ $routeProvider .when('/needsauthorisation', { //config for controller and template resolve : { //This function is injected with the AuthService where you'll put your authentication logic 'auth' : function(AuthService){ return AuthService.authenticate(); } } }); }).run(function($rootScope, $location){ //If the route change failed due to authentication error, redirect them out $rootScope.$on('$routeChangeError', function(event, current, previous, rejection){ if(rejection === 'Not Authenticated'){ $location.path('/'); }

Categories : Angularjs

AngularJS to Java Server to Payment gateway back to AngularJS
Overview of the solution: We solved the problem by having the AngularJS client create 2 separate request. One to our Java server, one to the payment-gateway. The Java server will keep checking for the payment-gateway to reply. When it does, it lets the client know what happened. More details: The client AngularJS makes an AJAX request to the Java server. The Java server, holds this request in a loop, constantly checking the payment gateway for success. When a reply is received, the server replies back to the AngularJS interface with the results. AngularJS interface then redirects to the correct page.

Categories : Java

how to test angularjs app with angularjs e2e with multiple inputs with same ng-model
I figured it out. i need to use using to focus the scope. example using('div[filter="search.username"]').input("filter").enter("foo"); using('div[filter="search.ami"]').input("filter").enter("bar")

Categories : Javascript

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



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