Login with AngularJS [closed] - angularjs

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to implement the following feature: whenever somebody comes to the site, he sees the login form and if he didn't logon correctly, any other url should show him login form.
how can I do this?
I have the project I inherited and only starting in Angular, so I have no idea where do I change the first page I show and how do I block unauthorized users from accessing other urls

To keep the explanation as basic as possible angular works in the main index.html file by using "controllers" to explain to the client browser what to do. Somewhere in your folder hierarchy should be a folder named "partials" , "templates" , "views" ,or something similar. It should contain a bunch of small .html files. Those files are swapped using AJAX embedded into angular. There should be an html element tag that contains an attribute "ng-app= "whateverYourAppsNameIsHere" within the opening element tag, anything in between this tag is "angular."
Angular seems complex at first, but once you keep at it it gets much easier. Everything within the ng-app attribute is powered in your JS files, and there's some really good free resources out there, including codeschool which has one, and angular. Google, hosts their own "phonecat app" which explains all the basics in pretty good detail in a walk-through tutorial with code snippets provided for when you can't quite figure it out. Make sure you use this link though [Google:Angular - Go to "tutorial"] (https://angularjs.org/) There is currently an Angular 2.0, which is written in TypeScript(short hand JS) found at FYI Only: Make sure you're not on this domain Know this exists in the event you start liking TypeScript, but I'd recommend sticking with plain angular until you're comfortable with it.
Okay, so that's a brief splash of what's what to find your files, and hopefully help you grasp any answers a bit better. At the very least those are 2 really good resources to start learning Angular from.
For your direct question "How do you manage users being logged in, or sending them to a page." There are many ways to perform that task, so I'll give you guidance on how to best learn it in my opinion. 1) Review "ng-if" which you can use to display/not display a page section (or as you asked re-route to a login form if not verified) People typically seem to use a "router" for Angular, Angular-UI is a fairly well recognized one and you can find it here: npm angular-ui-router. You can also verify someone on the back end when they call out to the server for page updates.
So I know I didn't directly answer your question, but the links I sent you will more than answer your question and also give you some guidance where to start learning/looking for resources from. If you're not yet familiar, I would recommend building/maintaining your app in Yeoman if you have not done so already. Yeoman and [Yeoman - tutorial] (https://www.youtube.com/watch?v=gKiaLSJW5xI) <-- This guy is AMAZING for tutorials, and he's very reassuring when you're scratching your head feeling overwhelmed with coding things.
Hope it helps, that's 3 years worth of resources touted out in 1 question response. Happy Coding! ;)

Related

Understanding Ionic [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am very new to ionic and still trying to learn. Few things I can't get a direct answers on this, hope for some help me. I went through few tutorials are articles, have an basic idea of ionic.
I am trying to develop a "group app". the group has 50 members.
I wish to publish event listings in the group app. Updating will be done
every week. So i can't exactly recompile this into apk whenever I do updating.
Also, I noticed ionic has a template that has login page. Where exactly does the username database stored?
If i need an admin section within ionic app, will it be possible? Whats the recommended method to do this?
If possible, I want this to do without any cost at all. I have a normal wordpress website that uses mysql database.
please help. thank you.
I am very new to ionic and still trying to learn. Few things I can't get a direct answers on this, hope for some help me. I went through few tutorials are articles, have an basic idea of ionic.
it is apparent from your questions, you've been reading recipe and not tutorials. They may have been labeled tutorials, but they were not. You are asking way too many questions, and the topics are too broad (wide).
To answer your question, in order
I am trying to develop a "group app". the group has 50 members. I wish to publish event listings in the group app. Updating will be done every week. So i can't exactly recompile this into apk whenever I do updating.
Your conclusion is based on faulty logic, and not understanding how Cordova works.
Also, I noticed ionic has a template that has login page. Where exactly does the username database stored?
Username and password storage is your issue, not Cordova's.
If i need an admin section within ionic app, will it be possible?
Yes.
Whats the recommended method to do this?
That's up to you. But understand you will be building it your self, likely from scratch.
If possible, I want this to do without any cost at all. I have a normal wordpress website that uses mysql database.
It is possible, but you will likely want to use a REST API to talk to the mobile App.
As you can see, my response appear to be vague, but that is because your questions are too broad.
I recommend reading this FAQ
Top Mistakes by Developers new to Cordova/Phonegap
If you have any further questions, I recommend following up on Google Groups Best of Luck.
I am trying to develop a "group app". the group has 50 members. I wish
to publish event listings in the group app. Updating will be done
every week. So i can't exactly recompile this into apk whenever I do
updating.
you can do this using ajax requests to server to get new events
and this is pretty easy by ionic using angular JS but it just need some time to try and read on how to make a restful ionic application
this will help you get the events from the database when the application opened
Also, I noticed ionic has a template that has login page. Where
exactly does the username database stored?
online database, just ready my answer to your first question
If i need an admin section within ionic app, will it be possible?
Whats the recommended method to do this?
yes it is possible but it is not recommended to do it in your public app
better to make web app for that
If possible, I want this to do without any cost at all. I have a
normal wordpress website that uses mysql database.
it will cost you nothing and you can use the MySQL database of your website
Good luck, you can make it, it just need some time and some searches

How to synchronize angular apps with togetherjs

I am trying to use togetherjs to make a live help feature for an angular web app. I put the together code in and it works on a basic level. You can see each other's cursors and chat etc. The problem is that none of the angular state data syncs. So when someone navigates to a different route the others don't follow them to the route. Is there a way to fix this? I have seen another question like this on SO but it hasn't been answered and I don't have enough reputation to do anything but answer it and I am seeking the same answer. Any help is much appreciated.

What should I choose: Meteor or MeanJS? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I wanted to get into full-stack JS development. I was about to start with the usual MEAN stack (MeanJS). I stumbled upon these articles:
http://wiki.dandascalescu.com/essays/why_meteor http://wiki.dandascalescu.com/essays/meteor_js_vs_the_mean_stack/
That are convincing. I am really confused how to get started. What are the pros and cons of using a frontend-backend-database framework like meteor over the conventional MEAN?
Due to the nature of the question, I'll try to answer it broadly. After using the MEAN stack for over 2 years and Meteor for a few months, I much prefer Meteor.
If you're just starting, Meteor has amazingly simple conventions. Try the angular-meteor tutorial to get started. Meteor offers one line installs, perhaps most notably including user authentication. You get the power of observables & latency compensation as a default.
The MEAN stack requires much more configuration and setup, as well as a strong developer foundation in Node.js. You have to do the work, but it may be worth it to understand the full stack. Much of what Express handles in dozens of lines of code can be handled in one line of code in Meteor.
Having said that, it is sometimes difficult to hack together Angular with Meteor. For example, I'm currently having difficulty using the new-angular-router with overlapping Meteor conventions. Consider MEAN has a much longer trusted history and wider support.
I think you are going to get a lot of opinionated answers, but to be honest every user is different and you won't really know until you try each out. I took a look at all the tutorials that were available for the ones that interested me.
ReactJs:
I was never a fan of reactjs, until the 3rd time I went through the tutorial, and thought this is kind of easy to get the hang of :
http://facebook.github.io/react/docs/tutorial.html
ReactJs is a framework by facebook and is doing pretty well. It works by updating the DOM and the syntax reminds me of that of programming a game. It uses states and props.
AngularJS:
I didn't prefer angular js as much because I didn't really give it much of a try (atleast more than twice). I was hypocritical about it. I thought of it as too much to remember and the tutorial I tried with it was this one :
https://thinkster.io/mean-stack-tutorial/
I think it is a great tutorial to get you into the stack. I can't say much about it but Angular 2.0 is coming out soon.
MeteorJS:
I never gave it a full go, but it looked interesting and from what I read, it was mobile friendly and great for single page app. Recently I've been following this tutorial:
https://scotch.io/tutorials/building-a-slack-clone-in-meteor-js-getting-started.
This is the next project I'm going to try to do in Reactjs(in meteor first).
I think its all really preference and you should just give all of it whirl. Some might be better at some functionality then others, some may be more syntax friendly, some may just be easier to use. All depends on the type of person you are.
Since Meteor is built upon NodeJS, it may be obvious that it was created to enhance development over the MEAN stack.
Meteor relieves the pain of writing hundreds of lines of code to accomplish a simple real time app, for example.
So if your question begins with "I wanted to get into full-stack JS development...", I strongly recommend you Meteor over MEAN.
At the end of the day:
"Meteor will be the JavaScript framework that will rule them all"

Can Angular JS be the replacement for template engines like EJS or Jade? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am new to MEAN stack. I have seen Template engines being used while developing node JS apps and realized it can be used to make static documents dynamic by integrating values from server.
However, I see Angular JS facilitates same stuff. Then why use template engines ? Is it absolutely necessary to use them? Can angular completely replace them ?
I think you're on the right track simi. When starting with Angular it is tempting to do "double templating" - templating on the server side and on the client side. Unless you absolutely need the server to render HTML your server should just be an API, the usual REST services serving JSON. Expose an API and treat your Angular application like any other client (Android, iOS). To see an example of this approach in action check out the Angular Fullstack Yeoman generator.
There are valid reasons to want the server to render full HTML responses, SEO probably being the most common. Whether or not it is worth the extra effort is a design decision.
As with all questions that are "this" or "that" the answer is "it depends".
First of all they aren't exclusive, so there isn't a reason to choose between them, but you should try to use them in a predictable way in your code base
Server side templates are good because it's generally less complex and it reduces client compute costs. If a part of your page doesn't need to be dynamic on the client side, it's a good candidate for EJS. An example might be a dynamic menu in a CRM application where you'll only change the content with config updates.
Angular (and other client-side MVW frameworks) offer lots of great things really. The first immediate benefit is that you can easily load dynamic content on the client side, which can result in better responsiveness and reduce the complexity of the backend (assuming you already needed an API layer, you can get a lot of stuff for free). A good example would be an auto-refreshing homepage feed which reloading the whole page is a waste. But most of that we've had for a long time with AJAX. Angular also makes it easy to generate the template so you can, once again, write less code and (if done right) more readable, testable code.
I think the right answer is to use both as you see fit.
NO. Angularjs cannot be the replacement for template engine like EJS or Jade. You need to use any one of the template engine. If you like ejs templating engine then you may use your angularjs code inside that template. Just suppose this is your regular html and you're including angularjs in it.

How do database driven blog-style websites work? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Before I start: I know this is a very broad question, but it is the best way I could phrase it, I have searched around a lot and can only seem to find generic explanations. I searched SO and didn't find much. I have also skimmed through some pages in the wordpress codex, and didn't find anything really useful.
I would like to create a simple database driven blog-style website, it will really only consist of stories (their title, date, content, etc), I just began teaching myself web development and my idea of how database driven websites work has proven to be completely wrong. I figured you would always need a file connecting to the database for each article, but the more I read I learn about mark up being generated on request, and so on, so the actual /year/month/day/article doesn't actually have to exist on the server, or that may be wrong, that is why I am here.
As I said I cannot find much on this topic that isn't a generic graphic of a server interacting with a web page. How does one go about creating a database driven website of this style? Are the files/directories not actually on the server but only created on a case by case basis as someone requests it? If so, then why can you type out a complete url and it be there with out throwing a 404? I have a lot of questions, really all I need is a strong explanation of how these sites work, code examples, and so on. Could someone explain how they work or point me to information (recommended articles, examples or books)?
EDIT: Please don't recommend a framework, I want to understand how these sites work and build one myself.
It's actually quite simple. Wordpress's index page calls wp-blog-header.php. That file calls for other files, and those files call for other files. It goes on for some time until all the contents of the page are actually loaded.
The databases come in when you start thinking about having users. Obviously the user information is stored in the database. Beyond that, Wordpress keeps post titles, dates, and other information in the database for easy loading later on.
Comments are also stored in the database. Each comment is associated with a number, and in the database, just like the posts, the dates/times as well as the usernames associated with the comments are kept.
Further exploration in the actual Wordpress files will reveal a lot of interesting features.
You might want to check out Django. It is an open source Python web framework that provides a lot of the functionality you are talking about. It also has a lot of very good high-level documentation with even a free e-book. It is centered a bit more on newspaper type sites than blogging, but most of the same principles apply. If you are new to python and like to use IDEs I would recommend checking out PyCharm. It has tight Django integration and makes for simple project setup and debugging.
Generally speaking, you'll use a framework that will take input parameters (year/month/day/article), run some code to fetch data from the database, and dynamically create the webpage. There isn't an actual .html file sitting on the webserver. One of the most popular frameworks to do websites like you're describing is Ruby on Rails, which makes it incredibly simple to do.

Resources