AngularJS template and AngularJS view differences - angularjs

What is the exact difference between Template and View in AngularJS.
Both terms are defined separately in the guide can be found here. Both seems to the same to me but question is lot of times people uses both terms for different purposes which i never understood till now.
I found some links on stackoverflow as well but its not answered correctly.
Could anyone please help me here to find out the differences ? (if any)

Related

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.

Login with AngularJS [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 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! ;)

Is there an AngularJS ORM

I came a across the following article while considering adding bacon.js and AngularJS:
https://github.com/ProLoser/AngularJS-ORM
But I could not find any other resources that would encourage (or discourage) the use of bacon.js in angularJs.
So I'm looking for some other resources on the subject? Does anyone have use the concept proposed by Dean Sofer? Does it work the magic promise?
Has anyone use the concept used in the video?
Sure this link can help you https://github.com/lauripiispanen/angular-bacon. Also I have my work with angularjs and bacon together https://github.com/xgrommx/angular-bacon-bridge.

How to implement Backbone boilerplate with views

I am trying to learn backbone, however truth be told, I'm feeling a little overwhelmed. Everywhere I look it is being done in a slightly different way, each with more frameworks and plugins to learn. So I have decided to put my faith in Addy Osmani and am reading his Backbone Fundamentals book. I have followed his recommendation and used the Backbone-Boilerplate. However for whatever reason, I have been unable to successfully install Grunt BBB so I cannot download the working examples.
What I am trying to do is follow this router section and use views. http://addyosmani.github.com/backbone-fundamentals/#router.js.
The problem is that I think these instructions are incomplete. For a start the collection.fetch() variable is in the wrong scope, and I really am not understanding where I need to place the views and how. I am pretty sure that if I could see a working example of this I could understand it, but as I said, everywhere I look its a different implementation.
Does anyone know how to use the backbone-boilerplate with routers and views? Are there any working examples anywhere?
Let me make a suggestion. A couple of months ago, I was where you are now: trying to learn backbone and trying to follow best practices while I did so. Like you, I came across Addy Osmani's book and like you I tried getting stated with backbone-boilerplate.
After much stumbling around, I eventually concluded that backbone-boilerplate was not something I needed to have while I was just learning backbone. It is now, only after having created a fully working, non-trivial CRUD application that I start to see how I might incorporate backbone-boilerplate. I think you probably need to be asking the questions that backbone-boilerplate answers (How can I break up my application into modules?, etc.) before you attempt to incorporate another framework or plugin. The same goes for Backbone.Marionette: great library, but you really need to have something to apply it to before using it.
Starting out, I would suggest having just a single file for all your backbone code.
One of the things that really helped me out was playing around with and extending various jsfiddle demos people had created using backbone. A simple google search will turn up quite a few. I found it a great way to learn as I was able to manipulate working code and get immediate feedback on what worked and what was allowed.
And although backbone is a client-side library, it's often simpler and faster just to ignore html and write stuff out to the console.
Finally, if you're willing to pay for it, I highly recommend Liam McLennan's set of backbone.js training videos on pluralsight.

backbone.js noob confused by conflicting tutorials [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm new to backbone.js and am working my way through some tutorials. I've found a couple that seem good, but there are some inconsistencies in how they implement so I'm looking for a little guidance on best practices.
Here are the tutorials I'm learning from:
http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/
http://coenraets.org/blog/2011/12/backbone-js-wine-cellar-tutorial-part-1-getting-started
My questions are:
The first tut makes use of Backbone.Controller but not Backbone.Collection. The second does the opposite. Which is the best practice for the "C" in backbones spin on MVC?
The first tut defines urls in the Model, whereas the second defines it in the Collection. Which is the better practice?
The second tut makes use of Backbone.Router, while the first one does not. Which is best practice?
Alternatively if someone can suggest a better intro tutorial that follows best practices I'd be happy to learn from there. Unfortunately because of the inconsistencies between these two, I'm concerned I might be learning some bad habits out of the gate.
Thanks in advance.
Backbone.Controller was renamed to Backbone.Router last year. I guess you were reading an old tutorial.
BackboneTutorials.com is a decent tutorial for getting started.
Build a small app as you learn and you'll know what Backbone does for you.
The best way to learn Backbone is to go through the annotated source code. Each and every line is commented and explained.
Use the dev version instead of the minified version when building your app. This helps in debugging.
If you are into reading books, check out Addy Osmani's Backbone Fundamentals, a free e-book. The book is awesome, but quite verbose. You can use it as a reference.
See this question on Quora for the definitive list of resources;
Don't worry too much about what's 'V' and what's 'C' and backbone's spin on MVC.
The framework does an excellent job of separating code that interacts with the server and the code that performs the core client logic. Templating and updation of DOM Elements is left to you. It's pretty minimalistic in that sense. Backbone provides Events that make the different parts interact with each other.
this is a good question. Though, Backbone isn't taking position on how you should organize your code.
So, the real answer is: it depends.
It depends on the need of your application and how you're used to program.
If you want an overview of some best practice, I'd refer you to the Backbone Boilerplate project: https://github.com/tbranyen/backbone-boilerplate
This project is pretty solid, and really helped me out when starting.
Then, to answer your question (this may feel opiniated, and it is indeed):
1: Backbone is mostly an MV* framework (Model-View-Whatever). Controller logic mostly live into Backbone view, and this is OK for front end developpement as logic is often really tied to the UI (as we are mostly coding interfaces). Backbone isn't coming built in with controller, but if you prefer this type of organization, just build your own.
2: Urls depends on your need. If you're fetching a full collection, set it up on the collection, if you're only fetching (or probably saving) one model, set it on the model. These too live well together.
3: About Router, if you're building multiple pages/sections on your app, use them. But beware of not using routes as action as you would do in RESTful APIs, this will most of the time brings problem eventually (user press back button, etc). So, use routes if you want to manage pages.
Hope this help !!
I will answer from experience:
Q: The second does the opposite. Which is the best practice for the "C" in backbones spin on MVC?
A: There is no Controller in current Backbone http://backbonejs.org/ - "C" happens either in View (most cases) or in Router (see below).
Q: The first tut defines urls in the Model, whereas the second defines it in the Collection. Which is the better practice?
A: There are cases when you don't need collections. In case when you don't, your model absolutely needs a URL. When you do have a collection, URL you specify for Collection will apply to its models.
Q: The second tut makes use of Backbone.Router, while the first one does not. Which is best practice?
A: Rule of thumb - you want to use Router in 2 cases: 1) when you want to have history, and 2) when you want to have permalinks. Otherwise you don't really need router.

Resources