These are chat archives for angular/material

7th
Jul 2015
Gaurav Saini
@gauravsaini03
Jul 07 2015 07:22
How we can have a global autocomplete (rather than writing filter, and all code in every controller for using it on different screens) ?
Like, I have a autocomplete for cities which fetch cities from APIs, rather than writing all the code (that is given in codepen example) on all controller, I am thinking to have it at common place and just get the selected value of it in all controllers and use it
Patrick Finkbeiner
@pfinkbeiner
Jul 07 2015 07:56
How about writing a factory/service and inject it wherever you need it?
Whenever I work with API’s I use factories…
Gaurav Saini
@gauravsaini03
Jul 07 2015 07:57
Shouldn't we use service for APIs ? or Factories are recommended anywhere ?
I think we can try with this and calling a serviceFor it
Patrick Finkbeiner
@pfinkbeiner
Jul 07 2015 08:01
Yeah, basically it doesn’t really matter what are you rely on… factories / services are mostly the same. I use factories, mostly if there is a model related to it (e.g. Users), services are great for some easy ReST calls. But I think you can handle it however you like… :smile:
Dave Ackerman
@dmackerman
Jul 07 2015 13:09
@gauravsaini03 you could just wrap that autocomplete in a directive, use a service for the shared data.
Gaurav Saini
@gauravsaini03
Jul 07 2015 13:10
auto-complete itself is a directive ! I am not sure how to do that, can you give me some example ?
Dave Ackerman
@dmackerman
Jul 07 2015 13:10
sure is.
just use the md-autocomplete in your custom directives template.
it will work :smile:
Gaurav Saini
@gauravsaini03
Jul 07 2015 13:10
Let me try it :D
Dave Ackerman
@dmackerman
Jul 07 2015 13:11
<custom-directive ng-model=“model.whatever”></..>
you may have to manually manage the ngModel from your directive.
Gaurav Saini
@gauravsaini03
Jul 07 2015 13:21
ok
Leandro Carlos Pereira
@lcpereira
Jul 07 2015 17:39
Hi
How can I limit a textarea, you put a scroll?
Gustavo Andres
@9andresc
Jul 07 2015 21:14
Which is best in your opinion? Angular Material or MaterializeCSS?