ngOfficeUIFabric / ng-officeuifabric

Office UI Fabric (https://github.com/OfficeDev/office-ui-fabric) implementation for Angular
http://ngOfficeUiFabric.com
MIT License
321 stars 67 forks source link

$dirty not being set on uif-textfield #367

Closed ghost closed 8 years ago

ghost commented 8 years ago

Refer to https://github.com/ngOfficeUIFabric/ng-officeuifabric/issues/361 for more information.

andrewconnell commented 8 years ago

See repo: http://plnkr.co/edit/n642ZGLz8VNgT5RjNO2L?p=preview

jjczopek commented 8 years ago

I had a look into this one and would like you guys to validate the approach. In one of the previous discussions it turned out we are not following exactly the same path as ng-material team, so I thought about going our own way.

Have a look at my fork, where I fixed the issue for the text field so far (not text area). I basically hooked into ng-change event on the internal input field and from there set $dirty on the bound model. I also hooked into blur event, where I set the $touched as this one was also missing. I think it's simple enough and it's not over-engineered.

Let me know what do you think about this approach. Code is in my fork, in the textfield-dirty-change branch: https://github.com/jjczopek/ng-officeuifabric/tree/textfield-dirty-change

andrewconnell commented 8 years ago

I really like this... seems very simple and easy to implement. Any downsides?

jjczopek commented 8 years ago

I haven't found any :) for text field it was easy enough because the events where already in scope, for other directives it might be necessary to add some events to the input, but I don't consider this as a downside.

Will raise PR for this soon and start working on other directives to have this covered as well.