angulardart / angular_components

The official Material Design components for AngularDart. Used at Google in production apps.
https://pub.dev/packages/angular_components
372 stars 123 forks source link

Not clear how to use material input #448

Closed Timmmm closed 4 years ago

Timmmm commented 4 years ago

This is one of the first things you'd want to do and it really isn't obvious how to do a basic binding to a <material-input>.

I did the same as in #24, and tried [(inputText)]="foo" and [(ngModel)]="foo", neither of which give compilation errors, but also neither of which work!

So apparently out you need to add install angular_forms, add formDirectives to the list of directives. I did that, but then it gives me this error:

dir.valueAccessor != null
"No value accessor for () or you may be missing formDirectives in your directives list."

Wait... I just added formDirectives to my directives list!!!

Ok let me Google error number 15.... aha. You have to use materialInputDirectives instead of MaterialButtonComponent.

It finally works! Please can you update this page with at least some bare minimum "how to" like this:

To use use <material-input> you should install the angular_forms package, then import 'package:angular_forms/angular_forms.dart'; add materialInputDirectives to your components directive lists (do not add MaterialInputComponent directly), and finally use <material-input [(ngModel)]="field"> in your HTML, where field is a member of your component class.

TedSander commented 4 years ago

That is specifically what the SOURCE link and the examples are for.... We don't want to put all the code in the doc comment itself.

Timmmm commented 4 years ago

I mean... yeah that's how I eventually worked it out, but it wasn't nearly as easy as if that paragraph were in the actual docs. I'm not sure I would call "read the source" good documentation. Up to you though I guess.