required directive inside in custom directive template and ng-invalid

1,497 views
Skip to first unread message

Krzysztof Danielewicz

unread,
Mar 29, 2012, 8:19:42 AM3/29/12
to ang...@googlegroups.com
I've tried to write a component using a directive with a template. 
I have a problem with conditional required directive inside my directive templete, the ng-invalid classes are not applayed to element.

Maybe my custom directive is not correctly designed. 

Here is a fiddle, 

there are a text input and my custom directive. After switch checkbox, required directive applies required attribute for both but it does not add ng-invalid class to a input rendered by my custom directive.

Any help?

Igor Minar

unread,
Mar 29, 2012, 3:09:24 PM3/29/12
to ang...@googlegroups.com
For input and other form controls to be databound and validated they need to contain the ng-model directive:


/i

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/iA8wZb3ifoQJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Krzysztof Danielewicz

unread,
Mar 29, 2012, 4:42:22 PM3/29/12
to ang...@googlegroups.com
Thanks Igor.

It looks ok. This example works great. 

The jsfiddle I was created reflects the problem in my app. Ironically in my app it is more complex and I think that the template uses required with ng-model. I hope it is my typographic bug, and ng-invalid is properly set.

I'll test it tomorrow in my app and tell how it is. 

Igor Minar

unread,
Mar 29, 2012, 5:16:24 PM3/29/12
to ang...@googlegroups.com
ok, let us know.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/tAhBixEW4GgJ.
Reply all
Reply to author
Forward
0 new messages