AngularJS remove ng-options blank value - html

<select ng-model="form.priority" ng-options="priority.id as priority.value for priority in leadPriority"></select>
It is showing blank option by default. How can remove it ?

Use ng-init in options
eg.
<select ng-model="form.priority" ng-options="priority.id as priority.value for priority in leadPriority" ng-init="form.priority = leadPriority[0].id"></select>

You can set in the controller as,
$scope.form.priority = $scope.leadPriority[0].id;

You can use ui-select which is more powerful version of select. You can find sample code for it here. You will need to include the js and css file from their library here.

Related

Disabled text-area in angularJS

I'm trying to put the disabled attribute in in angularJS It doesn't work at all, I've already tried ng-disabled="true", via script and it doesn't work. If I change it to it works normal, but I need to do it with the . Does anyone know how to do it?
Lets say you have a textarea like this
<textarea type="text" ng-model="someModel" ng-readonly="disablingAttribute"></textarea>
And inside your controller if you have
$scope.disablingAttribute = true;
It will functionally disable your textarea.
For more information on this, read about ng-readonly directive

Hide parent check box in ivh-treeview angularjs plugin

My Html Code is
<div ivh-treeview="menuPermissionObj.generalAssetManagement"
ivh-treeview-expand-to-depth="-1"
ivh-treeview-on-cb-change="changeCallback(ivhNode,ivhIsSelected, ivhTree)">
</div>
i used this plugin
https://github.com/iVantage/angular-ivh-treeview
is there any way to hide parent checkbox?
thanks in advance.
Yes, but you will need to use a custom node template.
See the list of supported helper methods and scope variables in your templates here: https://github.com/iVantage/angular-ivh-treeview/blob/master/docs/templates-and-skins.md#supported-template-scope-variables
Both isLeaf(node) and the depth variable will pair well with ng-show.

Select default option not working with Ionic Framework

I am using Ionic Framework.
I would like to enter the first option as the default, but doing it this way does not work.
What can I do?
<select ng-model="newSpesaAereo.valuta">
<option ng-selected="selected">Euro</option>
<option>Dollaro</option>
<option>Dollaro canadese</option>
<option>Sterlina</option>
</select>
If I analyze the page with Google Chrome Developer Utility I watch this.
If I edit this HTML and I delete the selected row, then Euro is visible.
Why is this happening?
Set ng-selected="true".
Example:
<option ng-selected="true">Carta di credito</option>
The reason the default option isn't working is because, in your controller, you've likely initialised your form model like so:
$scope.newSpesaAereo = {}
If you want to set default form options, you should also set them in the form model. For example, set 'valuta' to 'Euro' like so:
$scope.newSpesaAereo = { valuta: "Euro" }
I hope this helps!
P.S when posting issues like this you should also include the code for the controller that the view is bound to.
You need to use ng-selected instead of just selected.
https://docs.angularjs.org/api/ng/directive/ngSelected
<select ng-model="newSpesaAereo.metodoPagamento">
<option ng-selected="selected">Carta di credito</option>
<option>Bancomat</option>
<option>Contanti</option>
<option>Altro</option>
</select>

html selected disabled

I'm having trouble displaying the first option in a select element like this: http://jsfiddle.net/L6h9Q/
I want the first option tag to work as a placeholder but the second one is displayed first by default.
you can add selected="selected" attribute to the first option to put it on default.
Disabled items (by definition) cannot be selected. The item that is shown when the page is loaded is indeed selected.
The canonical way around this using plain JS and HTML is to leave that option enabled, then validate your form result upon submission (client- and server-side). If the user has selected the placeholder option ("City..." in your case), then let them know that they have made an invalid selection.
A workaround: http://jsfiddle.net/L6h9Q/2/
Essential part:
Add required to select;
Use select:invalid to make the color gray;
use option:first-child to make the first option gray.
Downside: works only on HTML5/CSS3 supported browsers.
Edit:
Inspired by #Russell, here's a (somewhat) better solution: http://jsfiddle.net/L6h9Q/3/
yes because It will show only enabled values first and then disabled values

what is text='<%#eval()>' in the html tags?

Yet i have not realized what is the diffrence between this two statement in HTML:
text='<%#Eval("some thing")>'
text='<%#Bind("some thing")>'
Please take a look on the examplke on MSDN, in this case using a repeater
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.aspx
also
How to: Bind to Data in a Templated Control
http://msdn.microsoft.com/en-us/library/95k0273d(v=vs.80).aspx