ang-auth's People
ang-auth's Issues
$state
You'll notice in app.js that we're injecting $state and using the method $state.go
to redirect the user to a specific ui route.
Break down the syntax of $state.go()
and explain what it's doing.
Refer to the documentation in here
Multiple Controllers!
This is a new idea to me.
When should we implement more than one?
res.render vs res.json
Do we always use res.json when using angular vs res.render? What is the difference??
READ THIS FIRST!
This application uses the todo code we worked on earlier in the week but includes Authentication and authorization with sessions.
Make sure your not inside of the wdi-remote-r2d2 class repo and then clone this repo to your local machine. Run npm install and you should be good to start nodemon and start exploring.
As you peruse the code you'll notice several things:
- The authentication syntax in the controllers directory is almost exactly the same as in Project 2
- There are no routes that render forms
- Routes send json instead of rendering views or redirecting
- Redirects are handled in
js/app.js
with$state.go
- The syntax in the router file is a little more robust using a pattern to set the controller and the controller as from the router rather than in each individual partial.
- Examine all of the
ui-sref
's and you'll notice some syntax to pass params. - Finally, CUIDADO, even though we have todos in this app, they are not yet embedded or in any way tied to a user.
As you look through this code I want you to make issues about code you're not sure about or nw syntax.
The title of your GitHub issue should contain the file name and the line number. In the body of the issue include your question or comment.
Feel free to answer each other's issues.
is app.js $http sending requests to the controllers routes
So just to clarify. The app.js is listening to events from the user and sending the request to the routes in the controllers folder.
The Router
Look at router.js, you'll notice some new syntax.
- Respond to this issue with the new syntax and discuss what it is doing.
- Trace the path of the edit route, can you pinpoint where we're adding content to the params and how we access it?
Read through this documentation for more information:
var self = this; (app.js line 5)
Can someone explain really what this does? I tried looking it up but didn't really get much.
user.js, Line 12, res.json()
What does res.json({user: user})
return? I'm thrown off by the .json
. We've had it before in other lessons but I never bothered to figure it out.
app.js:15 -- this.editedTodo = null;
this.editedTodo = null;
Is this just another way of writing a catch? What's the purpose of setting editedToDo to null?
server.js line 28 'secret'
Why 'keyboard cat'?
app.js line 49: is $state.params === $stateParams?
I think it is, based on https://github.com/angular-ui/ui-router/wiki/URL-Routing#url-parameters.
app.js line 35 (and elsewhere) =>
Is => just another way to declare a function?
router.js line 20-21 controller/controllerAs in a state
.state('login', { url: '/login', templateUrl: '/partials/login.html', controller: 'AuthCtrl', controllerAs: 'auth' })
We have not yet seen controllers being specified within a state. This concept is more unfamiliarity than confusion. I am assuming it is just another way to use a specific controller and when placed within a state, code becomes more clean (specifically the index html file).
server.js line 46/47 `mongoURI`
Is this a new var to be used for connecting to mongoose. This is a different var than we used in the past when hooking up our database.
Make sure to run mongod
just incase anyone cannot get their server up an running on the first try, make sure you open a new terminal tab and run mongod
EXAMPLE: App.js, Lines 29 - 38, $http.post()
// Explanation
$http a way to make http requests from the browser
.post means its an HTTP POST request, it takes a path as an argument, specifically, it's posting to /todos
and passing in the data for a new todo!
ui-sref in index.html
Can someone please explain what ui-sref refers too? Its assigined to the buttons in index.html. Does it have to do with the router?
app.js line 33 $state.go()
Is .go()
equivalent to res.redirect()
?
Full line of code: $state.go('allTodos', {url: '/todos'})
.
router.js, lines 14,38 params {key: null}
I understand that this is saying that there are no params, but why do you need it in the first place?
ng-submit="auth.signup(userPass)"
this feels like a question you ask after not paying attention in class and the teacher JUST said it.
but.. ng-submit = "auth.signup(userPass)"....
can someone break this down for me?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.