Page 1 of 1

ng-if example?

Posted: Thu Sep 10, 2015 6:12 pm
by Chris Ryhal

Not sure how to really go about this.

The values are populating just fine for me, but I actually want to do something special like change the text IF the value of {{laws.helment}} is true. That is actually a BOOLEAN value coming from the Appery Database.

So if its true, I would like to display "Helmet Required" if its false I would like "Helmet Not Required"

Image


ng-if example?

Posted: Thu Sep 10, 2015 6:34 pm
by Jack Bua

I am only familiar with jQuery, but it sounds like you need to put a little custom logic into the mapping from your service to the page, such as:

if(value) {
value = "Helmet Required";
} else {
value = "Helmet Not Required";
}
return value;

map that from the boolean object to the field on the page where you want the result to display.

Again, not sure how this translates to what you are using, but more pictures may help if you need more info.

NOTE: if(value) will only "trigger" if value is true. false and blank are considered false and do not trigger it.


ng-if example?

Posted: Thu Sep 10, 2015 7:03 pm
by Chris Ryhal

Hi Jack,

Yeah, I could easily tear this a new one with jQuery but I'm trying to get myself into the Angular world. I do appreciate your update and reply :)


ng-if example?

Posted: Thu Sep 10, 2015 7:20 pm
by Serhii Kulibaba

Hello Chris,

You are right. If you set nf-if={{laws.helment}} this component will be visible if $scope.laws.helment=true, else - invisible


ng-if example?

Posted: Thu Sep 10, 2015 7:25 pm
by Chris Ryhal

Ok, so that worked hiding. I understand that now, but how to change the TEXT to say something instead of just hiding it? I don't want it hidden, I want it to say

If True Then "Helmet Required"

If False Then "No Helmet Required"

I'm sure its something simple, I'm just not getting it.


ng-if example?

Posted: Thu Sep 10, 2015 7:31 pm
by Chris Ryhal

I guess what I'm looking for is kinda like a SWITCH statement. Maybe thats the answer, I'm just not familier with how to perform it within your framework


ng-if example?

Posted: Fri Sep 11, 2015 1:11 am
by Chris Ryhal

I'm sorry to be anxious, but I'm nearly there and this app is rocking!!!

HELP!


ng-if example?

Posted: Fri Sep 11, 2015 2:57 am
by Jack Bua

I wasn't aware that is was so different. My next app project is most likely going to be Angular. Hope I'm up to it.


ng-if example?

Posted: Fri Sep 11, 2015 7:03 pm
by Serhii Kulibaba

Sure, you can use ng-switch.
Also you can add 2 labels:
first one: set codetext="Helmet Required"/code and codeng-if={{laws.helment}}/code
second: set codetext="No Helmet Required"/code and codeng-if={{!laws.helment}}/code