ng-if="self_employment.business_type != 'Trust' || self_employment.business_type !== 'Partnership'"
Use != instead of !== :
ng-if="self_employment.business_type != 'Trust' || self_employment.business_type != 'Partnership'"
When You face this kind of problems, First check the object is defined or not. print the {{self_employment.business_type}} in the Html/console. If it is coming "trust/partnership" then it is in lowercase. if it is lowercase it may cause to fail the condition.
"trust" === "Trust" // false
"trust" == "Trust" // false
"trust" == "trust" // true
Related
Can someone expalain this code to me? I am getting a (false && false && why are you comparing a hyperlink markup?
{id === constants.ACCOUNT_NO && sessionState['backBtnAddressDetails'] &&
Confirm details }
The logic that the chained &&s implement is: the final expression in the chain, that is, the
Confirm details
gets rendered only if the prior two expressions are truthy.
Another way of doing the same thing would be:
{showConfirmLink()}
const showConfirmLink = () => {
if (id !== constants.ACCOUNT_NO || !sessionState['backBtnAddressDetails']) {
return null; // don't render anything
}
return Confirm details;
};
Another example of this, outside of React:
const theValue = 'abc' && true && 'theValue';
console.log(theValue);
If any of the expressions in an && chain are falsey, the chain stops evaluating there, and the whole thing resolves to that falsey expression. Otherwise, it evaluates to the final expression in the chain.
This type of expression is referred to as conditional rendering in React ,
basically if the condition is true, the element right (the Confirm details element in your case ) after && will appear in the output. If it is false, React will ignore and skip it.
it could mean the id and constants.ACCOUNT_NO aren't of the same type (when you use the === operator it strictly compares the types too )
another possibility is sessionState['backBtnAddressDetails'] could be null
I'm using angularjs and trying to set up a flag on the front end for my ng-if. I wanted to consolidate the logic in the controller but the the ng-if is only returning true and never false.
I need some efficient way for my code to return false if conditions are not met instead of returning undefined.
vm.showLocButton = !vm.isSupervisorReviewApp && vm.application.benefitPeriod.program.programType.id === vm.constants.programTypeId.directBill && vm.application.applicationStatus.code === vm.constants.applicationStatus.locIssued;
Dont know exactly but I see '=' instead of '==' are you assigninv the value or comparing if comparing than try using '=='
vm.showLocButton == !vm.isSupervisorReviewApp && vm.application.benefitPeriod.program.programType.id === vm.constants.programTypeId.directBill && vm.application.applicationStatus.code === vm.constants.applicationStatus.locIssued;
It will really helpful if you can post the entire code.
I am trying to hide or show my radio button using ng-if condition. Based on the formName return values.
<input type="radio" class="control-label" name="reportTypeRadios"
ng-value="reportType" ng-if="formName != 'DELETEREPORTTYPEENTITY' || formName != 'DELETEREPORTTYPESENTITY'"
ng-model="$parent.reportTypeRadio" ng-change="propertyRadioChanged(reportTypeRadio)">
{{reportType.reportTypeLabel}} </input>
But I am seeing the radio button in both forms. For some reason the ng-if condition does not work. Can someone suggest me what is wrong ?
formName != 'DELETEREPORTTYPEENTITY' || formName != 'DELETEREPORTTYPESENTITY'
This will always evaluate to true... Logically speaking:
If your formName is DELETEREPORTTYPEENTITY then your expression is going to be: (First part)false || (second part)true == true
If your formName is DELETEREPORTTYPESENTITY then your expression is going to be: true || false == true
If your formName is something else then your expression is going to be: true || true == true
I suspect that you wanted to write
formName == 'DELETEREPORTTYPEENTITY' || formName == 'DELETEREPORTTYPESENTITY'
so that you will only have the radio button showing up on those two forms that are named DELETEREPORTTYPESENTITY and DELETEREPORTTYPEENTITY, and nowhere else. Anyway, you should rework your condition to fit your needs.
The condition as in your code will always evaluate to true since formName can't be equal to both 'DELETEREPORTTYPEENTITY' and 'DELETEREPORTTYPESENTITY' at the same time.
Only way ng-if gets false is if both sides of || equate to false which can never happen.
I believe what you want to achieve here could be done by just one equality i.e.
ng-if="formName=='DELETEREPORTTYPEENTITY'"
I need something similar to the following script (this would ideally go into a LiveCycle "calculate" event field):
if(Subform.TextField1.rawValue !== null && Subform.TextField2.rawValue !== null && Subform.TextField3.rawValue !== null &&
Subform.TextField4.rawValue !== null &&
((TableSubform.Table.Row1.TextField5.rawValue == null && (TableSubform.Table.Row1.TextField6.rawValue == null && (TableSubform.Table.Row1.TextField7.rawValue == null) ||
(TableSubform.Table.Row1.TextField5.rawValue !== null && (TableSubform.Table.Row1.TextField6.rawValue == "Yes" && (TableSubform.Table.Row1.TextField7.rawValue == null) ||
(TableSubform.Table.Row1.TextField5.rawValue !== null && (TableSubform.Table.Row1.TextField6.rawValue == "No" && (TableSubform.Table.Row1.TextField7.rawValue !== null)) &&
((TableSubform.Table.Row2.TextField5.rawValue == null && (TableSubform.Table.Row2.TextField6.rawValue == null && (TableSubform.Table.Row2.TextField7.rawValue == null) ||
(TableSubform.Table.Row2.TextField5.rawValue !== null && (TableSubform.Table.Row2.TextField6.rawValue == "Yes" && (TableSubform.Table.Row2.TextField7.rawValue == null) ||
(TableSubform.Table.Row2.TextField5.rawValue !== null && (TableSubform.Table.Row2.TextField6.rawValue == "No" && (TableSubform.Table.Row2.TextField7.rawValue !== null))
)
{
this.rawValue="Complete";
} else {
this.rawValue="Not complete"
Basically, I have a form with four fields on top that need to be completed. Then, I have a three column table (first row being the header) with two rows of fillable text fields with the following rules in order for the form to be deemed complete:
If TextField5 is blank, then TextField6 and Textfield7 do not need to be filled in
If TextField5 is not blank, then TextField6 needs to be filled in with "Yes" or "No"
If TextField6 is "Yes," then TextField7 does not need to be filled in
If Textfield6 is "No," then TextField7 does need to be filled in
Please let me know where my script went wrong! Thanks!
First, from what I see this is not nested IF statement, it's a whole one command of and/or. Of course such code is not preferable, so first try to divide your conditions into something like this:
if(Subform.TextField1.rawValue !== null && Subform.TextField2.rawValue !== null)
{
if(another condition)
}
if(another condition).....etc
See, doing nested IF statements means for each command, there is other options to do.
For the conditions, if this language is JAVA then you need to use ActionListener
In order to write your commands in, it means when for example your TextField6 is "no", then using ActionListener you will write the command code that TextField7 need to be filled in.
If TextField5 is blank, then TextField6 and Textfield7 do not need to be
filled in. If TextField5 is not blank, then TextField6 needs to be filled in with "Yes" or "No".If TextField6 is "Yes," then TextField7 does not need to be filled in.If Textfield6 is "No," then TextField7 does need to be filled in.
Based on your description I would make a set of statements that look like this.
if (TextField5.isNull) this.rawValue = "Complete";
else {
if (TextField6.rawValue == "Yes") this.rawValue = "Complete";
else {
if (!TextField7.isNull) this.rawValue = "Complete";
else this.rawValue = "Not Complete";
}
}
But really, there's only one condition where you can have an incomplete form (it seems): TextField5 is filled, TextField6 is "No", and TextField7 is empty. So, you can condense that down into one statement and mark anything else complete.
if (!TextField5.isNull && TextField6.rawValue == "No" && TextField7.isNull) this.rawValue = "Not Complete";
else this.rawValue = "Complete";
I have 2 classes in and collapse and I want to apply both classes for same condition in angular js.
ex.
data-ng-class="{'in collapse': review.status != 'completed' && review.status != 'signedOff'"
can any one have idea how I can apply with this ?
Actually what you were doing is completely valid, you just forgot a closing curly bracket }
data-ng-class="{'in collapse': review.status != 'completed' && review.status != 'signedOff'}"