angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

default app should include CRUD angular UI for Things. #221

Closed ralyodio closed 10 years ago

ralyodio commented 10 years ago

Its a little confusing on how to stub out a client interface for doing CRUD operations. It would be awesome if we could have "Things" page for creating, reading, updating, and deleting them. At least as an option. The only create done in the UI is user, which uses both Auth and User and I'm a little confused on how to go about providing api/service for a Thing object.

DaftMonk commented 10 years ago

Actually, the 2.0 version will have a socket.io option, which will scaffold a real time crud interface for Things. For reference: https://github.com/DaftMonk/modular-fs/blob/socketio/client/app/main/main.controller.js

ralyodio commented 10 years ago

Can you provide an example with the current version? I'm not using sockets. I tried picking apart the User model to recreate it for Things using $resource, but I keep getting an undefined error when I call form.$save

educatedrisk commented 10 years ago

+1 on some basic examples with CRUD operations. Users, Products, Gallery or something of the sort.

ralyodio commented 10 years ago

I'm doing Post, but just crud on Things would be nice. Have it be an optional install if you don't want everyone getting it. But I've been stuck on this issue for like 3 days now. Cannot seem to figure it out.

Working example: http://plnkr.co/edit/KQR1EZPqW0MjLTorCmMr?p=preview

Fullstack code: http://plnkr.co/edit/5lFHCuCXyadIgXxG2YvB (here i get error: TypeError: undefined is not a function at form.$save())

Not sure where I'm going wrong.

DaftMonk commented 10 years ago

For an example with the current version: https://github.com/DaftMonk/mean-todomvc/blob/master/app/scripts/controllers/main.js

ralyodio commented 10 years ago

still getting TypeError: undefined is not a function on job.save(). I must be missing something obvious. It has something to do with this in the catch(fn(err)):

form[field].$setValidity('mongoose', false);
ralyodio commented 10 years ago

you motivated me to take a more aggressive debugging approach. I resolved it.

Confusion lies with $scope.form = {} and <form name="form" ng-submit="save(form)"> this does not work, as the objects collide.

I changed it to $scope.newJob = {}; and in view <input ng-model="newJob.title"> and <form name="job" ng-submit="save(job)">