Тёмный

How to casually change the entire way Angular components work 

Joshua Morony
Подписаться 74 тыс.
Просмотров 10 тыс.
50% 1

My Angular course: angularstart.com/
We recently looked at a new proposed format for Angular components that was developed by the community. This video takes a look at how this was accomplished on a technical level and how we can learn from other people's contributions to open source software.
The pull request: github.com/analogjs/analog/pu...
Get weekly content and tips exclusive to my newsletter: mobirony.ck.page/4a331b9076
Want to build mobile apps with Angular?: ionicstart.com
#angular #analogjs
0:00 Introduction
0:46 The basic idea
1:16 How to learn from PRs
1:39 Creating a TypeScript project
1:55 Installing packages
2:18 Parsing the file
2:54 Creating the target component
3:50 Using ts-morph
5:17 Thoughts
- More tutorials: modernangular.com
- Follow me on Twitter: / joshuamorony

Опубликовано:

 

11 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 59   
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Did you know I have a weekly newsletter? Keep up with my content and other cool stuff I find: mobirony.ck.page/4a331b9076
@craigritchie8470
@craigritchie8470 5 месяцев назад
Educational wise this is a great video. Thanks. New style wise… if you saw the 1000+ line *.ts files I deal with and the 1000+ line *.html files I deal with on a daily basis there is no way you’d be advocating for this single file format. LOL!
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I would still advocate for it because I would also be advocating for breaking up those components ;)
@MonaCodeLisa
@MonaCodeLisa 5 месяцев назад
When you put it like that it's much easier to follow :) definitely helps I so want to contribute and due to that huge skill miss-match between what I typically do, and what I see people doing I just feel like - maybe I should just sit back and observe. There is sooooo much to be observed, it really is like a hit in the face at first, but also so very very inspiring and a great learning source. Thank you for sharing this interesting, positive and encouraging video 👍
@chaos_monster
@chaos_monster 5 месяцев назад
Teaching AST, without mentioning AST :D nicely done
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
lol didn't really think about that - it wasn't a conscious decision to *not* mention ASTs but also I wanted this to focus more on "what can we learn directly from this PR" rather than specifically being a tutorial on what ts-morph is/what it does
@NikiHerl
@NikiHerl 5 месяцев назад
I was thinking along the same line "Tell me parsing is powerful without saying parsing is powerful"
@maksimhyena
@maksimhyena 5 месяцев назад
So basically, you want to turn Angular to Svelte?
@lukebennett3189
@lukebennett3189 5 месяцев назад
Seems like it
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Unless there's anything else I'm missing that distinguishes Angular from Svelte besides the component authoring syntax, then I guess so
@lukebennett3189
@lukebennett3189 5 месяцев назад
@@JoshuaMorony there’s nothing wrong with Svelte, I quite like it, but I preferred Angular over say React, because of its OOP design. Just a personal love that’s all
@Dorchwoods
@Dorchwoods 5 месяцев назад
Yes, that would be great. Haha
@krzysztofprzybylski2750
@krzysztofprzybylski2750 5 месяцев назад
​@@lukebennett3189interesting. I would do away with OOP, but I like that Angular is an opinionated framework. There's one way to do routing. There are established patterns enforced or strongly suggested by the framework. That way I can look at a new-to-me Angular project and understand what's going on.
@shemmuthanga6352
@shemmuthanga6352 5 месяцев назад
Great content as always. Thank you for showing us how simple some of this seemingly complex technologies are when we break them down to smaller bits and chunks
@3pleFly
@3pleFly 5 месяцев назад
Thanks to you I understand the basics of how this works and I think I am starting to lean towards adopting this in the future :)
@rubenheymans1988
@rubenheymans1988 5 месяцев назад
I really don't get how this is better? separated files are great and readeable
@akuoko_konadu
@akuoko_konadu 5 месяцев назад
Have been doing react and nextjs for over 3 years, and now my work requires me to learn Angular, and this has been a fun channel i discovered, learning new things day in day out, thanks Joshua 🙌 What distro of neovim do you use? And can you do a video about how to set it up for Angular and React development?
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I'm not using a distro but you can see my config here if you like: github.com/joshuamorony/nvim
@akuoko_konadu
@akuoko_konadu 5 месяцев назад
@@JoshuaMorony thanks, maybe I'll clone yours 🌝 My own is very shiny but it's slow as hell
@leiayuri
@leiayuri 21 день назад
Hi, would you know if I have a component A which extends a directive B. And in comp. a I am in injecting a service A with inject and inside of the constructor I am also calling super and injecting the service A. The question is, am I creating 2 instances os service A? Thanks in advance.
@it-s-me-mohit
@it-s-me-mohit 5 месяцев назад
Awesome video
@ianokay
@ianokay 5 месяцев назад
I don't like putting TypeScript in a tag and pretending it's native HTML, that seems tacky and disingenuous. is doing the same too right?. What's the purpose of such "faux-ity" and misdirection? 😑🤷‍♂ It's removing some clarity and honesty (you can call this "boilerplate" I suppose 😑) in favor of a dishonest representation, which I don't really get the point of. Do we favorite "simplicity" (which is also obscurity and dishonesty) in replacing an actually more straight forward representation, because the latter is more characters? 🤔 Isn't that just an issue better solved with tooling?
@neociber24
@neociber24 5 месяцев назад
For me having the logic and HTML on the same file makes so much sense because you are manipulating one with the other. The only reason I don't like this is because community split.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
These things don't specifically have to be there but I think the main motivation is that it is a format that makes delineating the specific parts easier (i.e. how should we distinguish which part is the template, which is the logic, which is the styles) and also because this particular formatting plays nicely with syntax highlighting/IDEs. It's also similar to conventions in other frameworks But, with enough work, the way the sections are distinguished could be just about anything
@ChauTran-xc4ld
@ChauTran-xc4ld 5 месяцев назад
@joshua lang=md on the template for example
@deefdragon
@deefdragon 5 месяцев назад
@@JoshuaMorony if the goal is to "delineating the specific parts easier", couldn't that be accomplished by just putting the separate parts in separate files? like angular already supports?
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
​@@deefdragon I don't know specifically how complicated this would make the implementation but hypothetically yes, just about any approach could probably be done. But at least from my view the SFC aspect is an important aspect of this proposal so there would still need to be some way to handle this for SFC as well
@jerrytab4276
@jerrytab4276 5 месяцев назад
welcome to Vue🎉
@SeySvK
@SeySvK 5 месяцев назад
no thanks, I like how separated it is right now
@maid768
@maid768 5 месяцев назад
With this new format, how would I add an html template of the child component (app-child) inside the parent components template (app-parent) Before you would write like template: app.child.component.html
@Tomas-ir8xl
@Tomas-ir8xl 5 месяцев назад
Any videos coming about signal inputs coming in Angular 17.1 very soon?
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I do have a couple of videos planned involving signal inputs but not sure when I will release them (and signal inputs are available now in the 17.1 RC btw)
@AbhinavKulshreshtha
@AbhinavKulshreshtha 5 месяцев назад
The best thing about open source, even if angular core doesn't accept this new format, someone will simply create a preprocessor transpiler to convert .ng file into core syntax. Most probably by extracting the logic from analog.
@marianbencat6658
@marianbencat6658 5 месяцев назад
If angular go with this formát, half of thé developers Will leave And new incomers Will go better with Vue / react. Keep this ONLY As experiment.
@CitizenCayne
@CitizenCayne 5 месяцев назад
Now that's Svetle-like. Things to come for Angular? A matter of fact, I think Angular should switch to versioning like Angular verson [YY-...] just like Samsung Galaxy naming convention like S23 Ultra --> S24 Ultra, etc I'd also LOVE to see the developer community STOP using "Hello" or "Hello World!" We are LONg pass he day when they "ping" the interest to send the first message of hello
@porcinetdu6944
@porcinetdu6944 5 месяцев назад
Really hope it never comes, love the OOP approach
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Hypothetically if you had to use just this new approach, what would you miss about the OOP approach?
@toxaq
@toxaq 5 месяцев назад
@@JoshuaMoronyseparation of concerns. I like that I think of the code as the view model and the template as the view. Putting it all in one file is convenient but will lead to spaghetti.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
@@toxaq this doesn't really have anything to do with OOP though, and even in the case of SFC it also doesn't really change anything in terms of actual code architecture, there is still three distinct places for the template/styles/logic, those three places just happen to be in the same file. In my opinion, this is a better representation of separation of concerns, because all of the things related to a specific concern (e.g. "rendering a button" or "displaying a list of data") are closer together - I don't see a "concern" as "this is the template part of this component" and "this is the logic part of this component"
@toxaq
@toxaq 5 месяцев назад
@@JoshuaMorony I wasn't commenting so much on OOP as "what I'd miss". Although in relation to OOP, its a stretch to say that page level vars are the same encapsulation as getters and setters on a class. I stick with my SoC argument. You could argue that they're all the same thing when combined on the page, my mental model is clearly different. I'm thinking in the page class about what I want to push through to the view. I tried Svelte and hated it. It became spaghetti for me with what ran in the server and what ran on the client. Maybe I just didn't wait long enough for that mental model to kick in. The seperate files was one of the reasons I jumped in to AngularJs in 2012. It felt natural and I'm super glad that Angular14+ is finally delivering on the promise. I don't have anything against the format/idea, I just wouldn't pick it and hope Angular doesnt confuse the waters by offering it.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
​@@toxaq so would it be fair to say (in summary) that the key things you prefer about the existing approach is the ability to define multi-file components and also having more strict control over what is exposed to the template? Although it's possible it seems unlikely that this new format will allow multi-file, but exposing variable statements as something other than protected only might be more likely. Hypothetically if both of those things were implemented, would you prefer the proposed format (e.g. ability to get rid of mandatory decorator metadata + class)?
@Alex-bc3xe
@Alex-bc3xe 5 месяцев назад
Looks like Vue or Svelte I think I don't know exactly anymore but seems too.
@toxaq
@toxaq 5 месяцев назад
Now can someone do this and let us have AngularNative?
@redfox2k8
@redfox2k8 5 месяцев назад
What's wrong with the original Angular format? I mean separation of concerns is there for a reason.
@marianbencat6658
@marianbencat6658 5 месяцев назад
Nothing just coming react fanboys tryint to destroy another good framework with their 20years old cykled mechanics
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Nothing specifically wrong with it imo, the SFC argument is a separate thing for me anyway I already use SFC with the current Angular format regardless and don't view the separation of technologies into different files as relating to separation of concerns. In my view, the code that relates to a specific concern should be co-located, having them in separate files just decreases their proximity (i.e. I see a "concern" as "rendering a list of data" not "this is the html for the list component"). If we could leave the SFC argument aside though, the new format just looks like an obvious improvement to me. The only real loss there is if you want to use inheritance with components which is generally not recommended anyway - otherwise there is nothing lost, but a lot less boilerplate and less concepts (like decorators) necessary
@redfox2k8
@redfox2k8 5 месяцев назад
Well components in Angular are very flexible, this flexibility comes from being able to configure it via the decorator. Think about standalone components, how are you supposed to manage imports, providers and stuff like that? Decorators are a very popular pattern in higher level languages. Yes your approach may seem „simpler“ at the first glance, but keep in mind that Angular is an Enterprise Framework with support for all kinds of complexity and project size. If your goal is a „simple“ component, maybe it’s just not the right tool for the job (although recent changes by the Angular team making it more and more universally usable)? Thinking about Vue or Svelte.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
​@@redfox2k8 the new format loses none of these things though, defining metadata is optional with this approach and it removes some of the need to add imports at all because a component can just be imported once and used directly in the template rather than also needing to add it to the imports of the decorator, its standalone by default, and it isn't necessary to define a selector for components (but you can if you want). However, with the new format you can also use "defineMetadata" to add the same things you would to a component with a decorator. This new format isn't just losing a bunch of features, it is just doing them in a different way - the only features that would really be lost is OOP stuff like inheritance since classes aren't being used, but inheritance isn't really generally recommended anyway.
@supirman
@supirman 5 месяцев назад
This just feels like going back to the old php days of one huge mess of a file with thousands of lines. I, for one, strongly prefer the segmented multi-file approach.
@sivuyilemagutywa5286
@sivuyilemagutywa5286 5 месяцев назад
If Angular adopts this format, this will kill Angular, I use Vue or Astrojs for simple or static website, but for bigger projects I always use Angular. I am not a fan of JSX, I don't like working with Vue syntax its painful to work with Vue template, but I tolerate it for simple projects. I have never used Analog so I have no comments.
@jpffinc
@jpffinc 4 месяца назад
And what is the difference between the template in angular and vue? What’s cause pain in vue template for you?
@sivuyilemagutywa5286
@sivuyilemagutywa5286 4 месяца назад
​@@jpffinc Before Previously in Vue, the Options API was the default, and I used to prefer setting up with Class Components due to my Angular background. Typescript felt like a hack with that setup. Then Vue 3 introduced the Composition API, which is similar to Angular's Class Components syntax in terms of functionality. However, a key difference is file separation. In Angular, you can have separate HTML, TypeScript, and SCSS files for each component, while Vue typically combines these into a single .vue file (Single-File Component). This file separation is a point of debate. Some developers prefer the one-file approach of Vue, while others (like myself) appreciate the organization and clarity of separate files. Ultimately, the choice depends on personal preference and project needs. In my opinion a lot of people who like Angular are not fans of javascript.
@rezonant
@rezonant 3 месяца назад
I agree, I use Angular exclusively and I'm not interested in this at all
@sivuyilemagutywa5286
@sivuyilemagutywa5286 3 месяца назад
​@@jpffinc Single-file components are a key difference in Vue. Instead of separate files for HTML, CSS, and Javascript, Vue uses a single .vue file (e.g., mycomponent.vue) for each component. While Angular allows both approaches, I initially tried replicating an Angular setup in Vue 2, including a clunky TypeScript integration. Vue 3 made integrating TypeScript much smoother, but transitioning from my preferred structure was a learning curve. Angular provided everything I needed out of the box: router, forms, services, HTTP, and TypeScript integration. Its structure felt familiar due to my experience with Java, C#, and PHP. While I appreciate Vue's flexibility, I ultimately found Angular's approach more aligned with my preferences and existing knowledge.
@user-hs9uf8fg5k
@user-hs9uf8fg5k 5 месяцев назад
trash
Далее
19. File Upload In NestJS
18:50
Просмотров 9 тыс.
CHROME OS Flex is a BAD operating system
18:39
Просмотров 117 тыс.
My NEW default for state management in Angular
6:21
Просмотров 29 тыс.
The inject function in Angular is not just a toy
3:55
as const: the most underrated TypeScript feature
5:38
Просмотров 110 тыс.
All Of The Harry Potter Professor's Bloopers
8:31
Просмотров 4,1 млн
Chrome OS y Windows: 5 principales diferencias
10:11
Просмотров 72 тыс.
The easier way to code Angular apps
9:54
Просмотров 64 тыс.