title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
|
x
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
|
Thursday, February 18, 2021 | |
I think Iโve mentioned Iโm stuck in an AngularJS (Angular 1) codebase for most of my work right now, which isnโt great. The portion of the codebase where I do most of my work is pretty solid, but there are lots of places where it doesnโt fully exploit what AngularJS had to offer.
I donโt love learning all this stuff about AngularJS in 2021, but thatโs the job. ๐ One solution that I keep suggesting is transclusion, which is where you embed html over into a custom component just like you would any other html element's tags.
And each time Iโve promptly forgotten how to use it.
So as a note to self, hereโs a [*coughcough*five-year old*coughcough*] video Iโve found that explains it fairly well:
Youโre welcome for cuing the video up past the annoyingly loud โWHAAAA!!!!โ at the beginning where heโs trying to solidify his self-branding as The Net Ninja.
Well, it turns out there's a lot more to transclusion than I'd hoped. Straight transclusion, where you want to drop html inside of your new custom tags just like they're standard html, and what I was describing before, is pretty much just as advertised. But then there's the situation when you want to have more than one transclusion. Say your custom component has a header, footer, and body. Do you have to parse stuff or can you set up three separate transclusions in your markup? Turns out it's the latter. (This is not covered in the video, above.) So if I have a wacky component like this one:
... and I map it up in my code like this...
... I can drop html into each by doing this...
... and have them pop into the right places. That's neat, I guess. Transclusion and uibModalWhich brings us to my actual use case. What I wanted to do was create One Modal to Rule Them All based on the AngularJS version of bootstrap UI, the $uibModal. And I wanted a component where you could pass in via transclusion the contents for the modal. So, you know, what I want is to take this conventional uibModal template:
... and replace it with something like this...
One problem: Where do I put the html for each transclusion spot? That is, how do I insert the equivalent of this for my modal? I don't really want to put it into a new template each time. That defeats the purpose.
You can't really insert into a template without the template. That is, uibModals aren't in their own component. You're already passing in the entire template, I believe (I'm not an AngularJS expert by any stretch, and I'm not really super psyched to be one where I don't have to, tbh). There are at least two questions on StackOverflow that seem related.
The first one has some code with a method passed to
So I'm still not real sure how to send over transcluded content, but that looks reasonably promising. For now, I've wimped out and created a new modal template type that takes a payload with messages and arrays of list items that the specialized modal turns into a display. For instance, here's the body that takes in
Feels dumb though. Labels: angularjs, noteToSelf posted by Jalindrine at 2/18/2021 09:42:00 AM |
|
| |
All posts can be accessed here: Just the last year o' posts: |
||||||||||||||||||||||
|