Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Kent C. Dodds
@kentcdodds
I believe it is...
Caleb Kniffen
@ckniffen
so then why wouldnt expressionProperties be used?
Kent C. Dodds
@kentcdodds
because it's not something that can be bound (like with {{ }} or ng- expressions)
Caleb Kniffen
@ckniffen
isn’t ng-keyup an expression
Kent C. Dodds
@kentcdodds
ng-keyup is a statement
not an expression
Caleb Kniffen
@ckniffen
oh I now see your point about about renaming it
yeah
In here I call it expression
should be statement

confusing

:point_up: that's what I get for trying to use hashtags in gitter
#confusing
Caleb Kniffen
@ckniffen
so there are three kinds attribute, bound and statement?
bound equates to {{}}? and uses expressionProperties
?
Kent C. Dodds
@kentcdodds
no, it's a little more complex
wish I had time to explain, but we're going to demo in a second and I have a bug or two to squash
Caleb Kniffen
@ckniffen
Thats fine
Kent C. Dodds
@kentcdodds
I think that's my next egghead.io lesson
Caleb Kniffen
@ckniffen
:)
Kent C. Dodds
@kentcdodds
because it's pretty complex, way powerful, very confusing
Benjamin Cabanes
@bcabanes
Hi guys, i have to do an "emptyIfEmpty" validation and i really don't know how to do it. Do you have implemented one?
Kent C. Dodds
@kentcdodds
I'm not sure what "emptyIfEmpty" means...
Benjamin Cabanes
@bcabanes
By emptyIfEmpty i mean:
i have two fields, if the first has a value, and the second hasn't, then the two must be empty
it's like dependent fields that have to be all filled, or all empty.
I don't really sure it is possible with formly, but i ask anyway
Kent C. Dodds
@kentcdodds
It's totally possible (and easy) with formly
I just don't have time to give you an example right now
Benjamin Cabanes
@bcabanes
okay, so this is a good news, an example would be super great! when you'll have time.
Kent C. Dodds
@kentcdodds
I recommend checking out the validation lesson at http://learn.angular-formly.com
Benjamin Cabanes
@bcabanes
yep i already tried that but i mess up with catching another value from the model but i will continue to try.
Ben Orozco
@benoror
you could write a failing jsbin example
Benjamin Cabanes
@bcabanes
i'll do that
Benjamin Cabanes
@bcabanes
Just make a jsbin http://jsbin.com/huhewo/4/ of the empty if empty failing
Ben Orozco
@benoror
@bcabanes the answer is in the validation example: http://angular-formly.com/#/example/other/toggle-required
by using expressionProperties to set required bound to each other, here's your jsbin fixed: http://output.jsbin.com/qodele/1/
Benjamin Cabanes
@bcabanes
@benoror I think this will do the trick, thank you!
Ben Orozco
@benoror
:+1:
Ken
@thekennysong
I am trying to use hideExpression and || . however hideExpression: 'model.primary_packaging !== "tray" || model.primary_packaging !== "shelf_carton"' doesn't work. I am sure it is small but idk how to fix it
Caleb Kniffen
@ckniffen
@thekennysong does it work without the OR?
Ken
@thekennysong
@ckniffen no i couldn't get it. I know it is a small little thing, but i tried a bunch of different combinations, no luck though
Caleb Kniffen
@ckniffen
where are you putting the hideExpression in the defintion? It needs to be at the top level (same level as key). That is a common mistake.
Ken
@thekennysong
                        key: 'quantity',
                        type: 'input',
                        templateOptions: {
                            label: 'Quantity',
                            type: 'text'
                        },
                        hideExpression: 'model.primary_packaging !== "tray"'
                    }
it works with 1
Kent C. Dodds
@kentcdodds
Make sure that the logic is doing what you think it's doing.
'model.primary_packaging !== "tray" || model.primary_packaging !== "shelf_carton"' means that the field will hide if the primary_packaging is not equal to tray or shelf_carton
If that's what you're trying to do, then could you make an example: http://new-example.angular-formly.com
Kent C. Dodds
@kentcdodds
@/all I will only accept a PR for this one if you haven't ever contributed to open source before :-) https://github.com/formly-js/angular-formly/issues/343#issuecomment-111495740