Chris Ryhal
Posts: 0
Joined: Fri Aug 15, 2014 1:09 pm

ng-if example?

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

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

ng-if example?

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.

Chris Ryhal
Posts: 0
Joined: Fri Aug 15, 2014 1:09 pm

ng-if example?

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

ng-if example?

Hello Chris,

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

Chris Ryhal
Posts: 0
Joined: Fri Aug 15, 2014 1:09 pm

ng-if example?

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.

Chris Ryhal
Posts: 0
Joined: Fri Aug 15, 2014 1:09 pm

ng-if example?

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

Chris Ryhal
Posts: 0
Joined: Fri Aug 15, 2014 1:09 pm

ng-if example?

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

HELP!

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

ng-if example?

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

ng-if example?

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

Return to “Issues”