my HTML code for drop down like follow:
<select ng-model="selected_value"
ng-options="(x.version + ' ' + ' : ' + x.status) for x in allData"></select>
my Angular code like follow :
data comes from a rest service
$http.get(......).success(function (data, status){
$scope.allData = data;
$scope.selected_value = $scope.allData[0].version + " : " + $scope.allData[0].status;
});
Data comes to the drop down. but initially drop down does not display the value. It shows if only select the value. Can someone help on this issue.
Add ng-selected="selected_value" to the select element.
An example of what you are trying to achieve can be found in the ngSelected documentation.
Related
I have the following input field:
'<input check-value-type' +
' type-value="$$node.type_value$$" ' +
'ng-repeat="input in inputs track by $index" ' +
'type="text" ' +
'placeholder="Value ($$node.type_value$$)"' +
'class="form-control" ng-change="changeArrayValue()" ' +
'ng-model="node.value[$index]">' +
How to pass current value into: ng-change="changeArrayValue()"
I tried as: ng-change="changeArrayValue(node.value[$index])"
As I can see from your code; you are creating Angular JS directives / html code within your js file.
This is totally wrong ! !!! and you shall not do that.
Add a proper template; than you can access to the value with ng-model
I am not sure if what you are doing there is correct but if you have a value field in the input tag then I think you are looking for $event.target.value
Try ng-change="changeArrayValue($event.target.value)
I have an array that is outputted and displayed using ng-repeat, with the list and example data being as follows:
List display:
<li ng-repeat="ingredients in recipeObject.ingredients">
{{ ingredients.amount + ' ' + ingredients.unit + ' '+ ingredients.ingredient}}
</li>
Example object:
$scope.recipeObject = {
ingredients : [
{amount:1, unit:"tablespoon", ingredient:"Olive oil"},
{amount:0.5, unit:"", ingredient:"Red onion"},
{amount:2 , unit:"", ingredient:"Bay leaves"}]
}
Which will display something that looks like
However, I would like to be able to replace values such as 0.5 with values such as "Half", so the displayed value would read something like "Half a Red onion".
I do not want to change the amount to the string, as the amount being numeric allows me to compute important data.
Is there a way to conditionally change the displayed amount, such as if the amount is a decimal value, to a different format?
Alternatively, having a display filter that changes the decimal value to a fraction is acceptable too.
There are several ways:
Best (scalable/angular-ish) - filter (as mentioned above)
Ugly:
<li ng-repeat="ingredients in recipeObject.ingredients">
{{
ingredients.amount==0.5?'half':
ingredients.amount==0.25?'quarter':
//etc...
ingredients.amount
+ ' ' + ingredients.unit + ' '+ ingredients.ingredient}}
</li>
Easy
<li ng-repeat="ingredients in recipeObject.ingredients">
{{ myFormat(ingredients.amount) + ' ' + ingredients.unit + ' '+ ingredients.ingredient}}
</li>
And inside controller:
$scope.myFormat = function(input){
if (input == 0.5) return 'half';
else if (input == 0.25) return 'quarter';
//etc...
else return input
}
I am trying to populate a column that is to represent an Internal URL that directs the user to a specific document. The document ID, DOC_ID, is already populated in the Table. I would like to populate the column by prepending a base URL to the Document ID. I do not know how to to do this dynamically and am getting some errors referring to the parameters of CONCAT(), issue being it is understanding it to be a string rather than the column value. My code is as follows:
SET #Insert_DRS_URL_SQL = 'UPDATE'
+ ' '
+ QUOTENAME(#TBL)
+ ' '
+ 'SET DRS_URL = CONCAT(#URLBASE'
+ ','
+ 'DOC_ID'
+ ')'
EXECUTE sp_executesql #Insert_DRS_URL_SQL;
UPDATE
#URLBASE = 'http://blah/blah/blah/id='
DRS_URL is the column I wish to populate.
Basically I need DRS_URL = #BASEURL + DOC_ID
I'm trying to execute a dynamic soql query using variable objects.
In my visualforce page i have tow apex:selectlist, the first one contains a list of objects, when i select one object from this list, i refresh the second list to display selected object's fields.
The apex:inputText contains text to search in selected field.
visual force code:
<apex:selectList id="listObjects" value="{!selectedObject}" size="1">
<apex:selectOptions value="{!allObjetcs}"></apex:selectOptions>
</apex:SelectList>
<apex:selectList id="listFields" value="{!selectedField}" size="1">
<apex:selectOptions value="{!allFields}"></apex:selectOptions>
</apex:SelectList>
<label>Text to search : </label><apex:inputText id="textResearch" value="{!textResearch}" />
<button id="searchButton" type="button">{!$Label.SEARCH}</button>
apex code :
public void search() {
result = new List<SearchWrapper>();
System.debug('>>>>>> ALK - in search ');
String query = 'Select Id, ' + selectedField + ' from ' + selectedObject + ' where ' + selectedField + ' like \'%' + textResearch + '\'%';
System.debug('>>>>>> ALK - Query : ' + query);
List<sObject> = (sObject) Database.query(query);
}
Please how can i cast Database.query(query) and how can i execute this dynamic query.
Thanks for all.
if you are using a local variable in your query you must put ':' before that. like this:
String value = 'test';
List<something> result = [select id from something where name = :value];
Try below code. If field list if multiselect, you might have to iterate over the selectedField variable and form a string of field names separated by comma.
String query = 'select '+String.valueOf(selectedField)+' From '+selectedObject+' WHERE Name = \'' + textResearch+'\'';
List<sObject> recordList = Database.query(query);
public void search() {
result = new List<SearchWrapper>();
String query = 'Select ' + selectedField + ' from ' + selectedObject + ' where ' + selectedField + ' like \'%' + textResearch + '%\'';
System.debug('>>>>>> Query : ' + query);
List<sObject> l = Database.query(query);
}
am using devexpress winforms reports, I can able to set one filterString condition in code, this code is working successful
report.FilterString = "CompanyId =" + compid;
and
DetailReport.FilterString = "CompanyId=" + compid;
But now I need to set for two conditions I tried this code but it didn't filter display all
values.
report.FilterString = "[CompanyId = " + compid +"] AND [ InvoiceStatus =" + status + "]";
Help me how to solve this ?
The simplest filter syntax looks like this: "[FieldName] = Value".
Thus, change your code as follows:
report.FilterString = string.Format("[CompanyId] = {0} AND [InvoiceStatus] = {1}", compid, status);
Thanks to all. Finally solved by this code and working fine for two filters using correct string formats.
report.FilterString = "InvoiceStatus = '" + status + "' AND CompanyId = " + compid;