juristr / juristr.github.com

My personal website and blog
http://juristr.com
21 stars 16 forks source link

Angular 2 - FAQ / Commonly asked questions #8

Open juristr opened 8 years ago

juristr commented 8 years ago

Hi,

I'd like to create a blog post, collecting and answering some most commonly asked Angular 2 questions and would be happy to get them from you :smile:. I'm curious what puzzles you most. Besides that, your questions will help me get some valuable input for my Angular 2 screencast series I'm currently working on.

So, you're an Angular newbie, or simply getting started with Angular 2? You don't know where to start? Ask your question here, I'll collect them and publish a blog post, hopefully with some hints & answers!


Questions

..aggregated out of the comments below

(Once I have a couple, I'll publish the post with answers and check them here)

EmmanuelDemey commented 8 years ago
juristr commented 8 years ago

@Gillespie59 thx for your questions.

What the workflow we should follow before deploying our Angular2 into production ?

What exactly do you mean by that?

etw3gh commented 8 years ago

Does the angular-cli build command replace gulp? Does it handle bower

juristr commented 8 years ago

@openciti :+1: , added to the list.

Does it handle bower

Could you provide further details? What do you mean by "handle"? Doing the install which bower does?

cpiock commented 8 years ago

How to organize folders and files in angular2?

cpiock commented 8 years ago

And naming conventions for files

juristr commented 8 years ago

@cpiock That's already in the list :smile:

etw3gh commented 8 years ago

handle bower as in copy only the required files to the dist foder upon build. replace gulp as in minify and concatenate etc...

EmmanuelDemey commented 8 years ago

@juristr

What the workflow we should follow before deploying our Angular2 into production ?

Does the ng build task is enough when we want to deploy our app in production ? Are minification and concatenation supported by the ng build task. Should we still use gulp or grunt ? ...

juristr commented 8 years ago

@Gillespie59 Oh, I see, you're talking about the CLI project. So you mean like "what's a good workflow to create a distribution package that can be deployed in production".

//update: I'm still a bit skeptical whether the angular-cli will succeed. It will certainly help newbies get started much quicker and that's a big benefit. But when I think about all the features and flexibility Gulp or Webpack give you... But we'll see, the project is still too much in alpha :wink:

cpiock commented 8 years ago

What type of routing should we use # or html5 route?

cpiock commented 8 years ago

Should we use grunt or gulp or something other for angular2?

juristr commented 8 years ago

@cpiock

What type of routing should we use # or html5 route?

That's actually a generic question and not necessarily angular 2 specific. Generally speaking it really depends on the browser's you have to support and how you're backend application is being organized. I tend to prefer the HTML5 pushState api over hashbang URLs, as they're much "nicer" for the end-user. However that has implications on how you deliver your application. Like, the backend server has to acknowledge the frontend-routes and deliver the according startup HTML file (index.html), rather than returning a 404, because obviously no server-side resource would exist for such path.

cpiock commented 8 years ago

should i redirect all generated typescript javascript and sourcemaps to a specified directory?

juristr commented 8 years ago

should i redirect all generated typescript javascript and sourcemaps to a specified directory?

@cpiock There's no right or wrong. For toy examples it obviously doesn't matter. But for larger apps I personally prefer to do so.

cpiock commented 8 years ago

@juristr ok. is there a best practice where to move it or i define my own folder like jsgenrated or something else? and this js files are like dll's. so they don't go to my source repository?

cpiock commented 8 years ago

when i should use names like xy.component.ts and when only xy.ts?

juristr commented 8 years ago

@cpiock: there's Minko's community driven styleguide amd John Papa is about to create one for version 2 as well. Check the links in my starting post to this issue

ratnabh commented 5 years ago

How can I pass my data from shopping component to shopping-list component and add in the ingredients array? I tried but faced some issue here is link to the code

https://gist.github.com/ratnabh/61776fae47421be47113904133d8bc24

juristr commented 5 years ago

@ratnabh Could you create a Stackblitz s.t. I can give it a look? That takes less time on my side to help you out 😉

ratnabh commented 5 years ago

well @juristr i have solved it.Thanks though :-)

ratnabh commented 5 years ago

In my project of building Shopping list i tried to pass a selected data from my header.component.html to app.component.ts via services and then tried to just console.log in app.componwnt.ts .But i see that nothing is being printed and neither i am receiving any error .Here is the gist link to it.Any help will be highly appreciated.Thanks ! No stackblitz please :-) https://gist.github.com/ratnabh/87847c8396a32436b8a751eb5bb08ae8