These are chat archives for angular/material

12th
Jul 2016
Daron Jones
@Wuntenn
Jul 12 2016 10:43

@aaronksaunders Not sure exactly what you currently have (is it an md-tab?) The $stateChangeStart event that you’re using is fired as the page state is about to be transitioned to another state (route). Look into: https://github.com/angular-ui/ui-router/wiki

You say that you want the page to change on refresh (dom ready). look into: http://stackoverflow.com/questions/18646756/how-to-run-function-in-angular-controller-on-document-ready

Also as @felixfbecker asks, why the timeout?

Daron Jones
@Wuntenn
Jul 12 2016 10:53

@akeucon maybe use the controller more instead of the view. You have the dataset in the controller in the firstplace and the repeated section is bound to that data. So have a 'select all' button that references a controller method by the same name.

In the controller method iterate the dataset and update the selection/de-selection. If that fails to work as intended, I suspect this would be more of a cause of making sure that the view stayed sychronous with the data. In this case you’d be looking into using $watch or something similar to force update.

Alex
@atodicebear
Jul 12 2016 11:22

@Wuntenn Thx for an answer.
But i dont want an Extra Button. I have a Dropdown List which shows me all Datas which i can select.
They are coming dynamically from a Database. So now i wanna one "static" field shown on top of the List in the Dropdown which selects/show.
Or deselect/reset the filter?
I htought there is maybe an optiin in angu-material for dropdonw ? filter?
so thats the code

<md-select ng-model='search' placeholder='Please Select a Key ID'>

<md-option ng-repeat='key in $ctrl.Keys' value='{{key._id}}'>{{key.name}}</md-option>
</md-select>
and then maybe something ng-reset=''...?

Another Question as Bonus ^^
Im working at the moment with Checkboxes.

<tr dir-paginate="value in $ctrl.Values | orderBy:'-_id'|filter:{key_id:search}| itemsPerPage:3" pagination-id="value">
<td><md-checkbox class="md-secondary" ng-model="change" aria-label="change" ng-click="$ctrl.check(value)" ng-init="value.translate"></md-checkbox></td>
<td><md-checkbox class="md-secondary" ng-model="check" aria-label="check" ng-show=value.translate></md-checkbox></td>
<td><md-checkbox class="md-secondary" ng-model="admit" aria-label="admit" ng-show='value.check'></md-checkbox></td>

When i click on a Checkbox i call the check Method
check(value){
console.log(value);
if(value.translate === false||value.translate === 0 || value.translate === null){
this.$http.put('/api/dict_values/'+ value._id,
{
user_id: this.currentUser()._id,
translate: 1,
});
}else{
this.$http.put('/api/dict_values/'+ value._id,
{
user_id: this.currentUser()._id,
translate: 0,
});
}
}
but its working only once?
I mean i log in go on page click checkbox it updates the Data in true if i uncheck nothing happens?
Have i here to work with $watch ?

Daron Jones
@Wuntenn
Jul 12 2016 11:29
This message was deleted
Daron Jones
@Wuntenn
Jul 12 2016 11:37

Hmm I don’t think you should have used ng-init to do this. Read the big red warning: https://docs.angularjs.org/api/ng/directive/ngInit.

Use the controller and bind properly then you get the two way binding for free not just initialisation

Alex
@atodicebear
Jul 12 2016 11:42
@Wuntenn yeah i saw that and there stands "and for injecting data via server side scripting". As i understood it is what i want to do or not ?
Get from Server Database a Value true/false and initialize the button so it is shown as "set=true/or not set=false"
Because at the moment on my Page the value is true but the box dont show the checkmark
Daron Jones
@Wuntenn
Jul 12 2016 11:52

@akeucon You’re doing things the hard way! You’re doing all the leg work to maintain the items on your db. Use ngResource.

At the moment you have your RESTFUL api. But you are calling PUT/GET etc because you know what you need to do as a developer. But ngResource is something thats easy to set up. You use it like you would use a controller. You tell it your API base path /api/dict_values/ and give it a name e.g: todo to make a TodoService

You can then inject the service where you need. So in the controller that you’re using you would inject it. You can then do things like todo.$update and behind the scenes it will call PUT with the correct payload. Read this: https://www.sitepoint.com/creating-crud-app-minutes-angulars-resource/

Alex
@atodicebear
Jul 12 2016 11:54
@Wuntenn yeah sorry im fully new to this so the most lines are "hardcoded" and not generic to be usefull everywhere... :(
Daron Jones
@Wuntenn
Jul 12 2016 11:57
When you work this way you just have to keep the items up to date and worry about saving the items. e.g.: https://github.com/meanjs/mean/blob/master/modules/articles/client/services/articles.client.service.js#L28-L33
Alex
@atodicebear
Jul 12 2016 12:04
im working with this
https://github.com/angular-fullstack/generator-angular-fullstack
i have to check if there is allready something liek this implemented or i have to add
Daron Jones
@Wuntenn
Jul 12 2016 12:10
No worries we all start someplace. I’m still newb too. Read that tutorial I sent. Then look at the the framework properly before you move on
Daron Jones
@Wuntenn
Jul 12 2016 12:20

@akeucon Just had a quick peek. At the bottom of the page it shows you the generators. They are scaffolding commands that will set up stuff that you do lots of the time. Think now with hindsight. What else might you be doing the long way. The best tools for the job are probably scaffolded in there somewhere.

This means that you want to look at whats generated so that it’s not magic. You want the scaffolding to be like shortcuts that you wrote for yourself because you got bored of doing it tons of times. Not like magic tricks. That time is more useful than time you will spend doing thing that might be the long way around. Also if you decide not to continue with angular-fullstack, you’ll have a better sense of what’s going on. Stick with that stack though until you know it really well. It will give you a map to compare and contrast other frameworks against.

If you get time. (i alway plug this book but its awesome!) Amos Haviv: https://www.amazon.co.uk/MEAN-Web-Development-Amos-Haviv-ebook/dp/B00NXWI1BM/ref=sr_1_1?ie=UTF8&qid=1468325905&sr=8-1&keywords=amos+haviv best angular book IMO that you can get (This book is where I started. No confusing hopping from one tutorial to the next) You build a smaller framework from scratch. When you’re done you will understand these frameworks much better and why to use one or the other depending on the size of your project

Alex
@atodicebear
Jul 12 2016 12:31
@Wuntenn Thx for the info. Problem is i have time Issues and so much more to do.
Thats why i startet with an fullstack generator and not from scratch because i thought the most would be implemented.
Problem is now the most is implemented but not well Documentadet which/how/why/what to use when i need something.
As example $ressource is in there somewhere seen but not the Update command.
And it generated for me a get request but why not using their own $ressource.get? so thats why im at the moment more the long way hardcode.
After im done with this project i think i will understand more and do more own factory/services/modules and so on...
but for now cry in the corner :D
But thx for the suggestions.
Something in addition to the Button Initilisation or selectFilter Problem?
Daron Jones
@Wuntenn
Jul 12 2016 14:50
@akeucon read bits an pieces when you can . But that book will save you back the money and the time it costs to buy and read it!
Chris Coggburn
@noderat
Jul 12 2016 23:23
Is there somewhere in the documentation that i'm missing that lists all of the various classes? For example, I see .md-toolbar-tools in the md-toolbar example but I can't find anything specifying what it's actually used for