In Aurelia 1, you could access the controller of an Aurelia component by accessing au.controller of an element. In Aurelia 2, there is a better way using the CustomElement.for method, which provided an element with a controller that will return it.
const dialogController = CustomElement.for(host.querySelector(".my-component") as HTMLElement); const dialogVm = dialogController.viewModel; You can also access a property on the element if you prefer using: element.$au['au:resource:custom-element'] – but the provided method might save you the hassle of having to type things if you’re working with TypeScript.
When will companies learn that despite some people wanting to be in an office, many people who have been given a taste of remote work during the pandemic don’t want to return to the office?
One of Australia’s largest banks, Commonwealth Bank, conjured a storm of epic proportions last month when it announced it wanted all 49,000 employees back in the office at least 50% of the time by July 17, 2023.
One of my favourite additions to Aurelia 2 is app tasks. These are framework-level entry points designed to allow you to run code at different points of the framework life cycle.
Recently, while porting over an Aurelia 1 application to Aurelia 2, I encountered a unique use case where code was being run inside configureRouter to asynchronously fetch data from an API to provide metadata for routes.
In Aurelia 2’s @aurelia/router package, you set routes using a decorator or a static routes property. How on Earth do you run code that touches the routes before the router gets them?
When migrating an Aurelia 1 application to Aurelia 2 recently, I had to deal with many routes I needed to convert tediously. As you might have discovered, the Aurelia 2 @aurelia/router is different to the Aurelia 1 router.
Not wanting to change 50+ manual PLATFORM.moduleName values, I opted for a regular expression. I hate RegEx because I don’t understand it, but you cannot deny its power. Here’s the solution I used.
There is a growing divide in a world filled with out-of-touch billionaires and misguided wannabes who follow their words as if they were holy scripture. On one side, we have the tech titans like Elon Musk, who believes that people are more productive in person and criticises those who advocate for work-from-home as being on a “goddamn moral high horse”. On the other side, we have the workers, many of whom have experienced the benefits of remote work and yearn for a more balanced life.
Who else had this on their 2023 bingo card? In the midst of a global cost of living crisis, two tech titans have presented us with an unexpected yet entertaining proposition: a cage fight.
Elon Musk, the audacious CEO of SpaceX and Tesla, has indirectly challenged Facebook’s Mark Zuckerberg to a cage fight. And funnily enough, Zuckerberg seems to be down for the challenge.
This playful feud started on Twitter, where Musk has been taunting Zuckerberg with zingers like “Zuck my 👅.” During an internal all-hands meeting at Meta last week, chief product officer Chris Cox told employees the company thinks creators want a version of Twitter that is “sanely run,” drawing cheers. In a recent podcast interview with Lex Fridman, Zuckerberg added, “I’ve always thought that Twitter should have a billion people using it.” which felt like a pointed jab.
Well, this is sad news. Nestle has announced they will no longer be producing the beloved chocolate-covered chewy caramel treat Fantales, which have been around for almost a century. I have fond memories of eating these as a kid, and I still buy them occasionally.
They are being discontinued because of declining sales and upgrades that need to be made to equipment at their Melbourne factory to keep producing them. I’m guessing the cost of living crisis and the rising cost of doing business are also factors.
In a move that caught everyone by surprise, Google recently announced the sale of Google Domains to Squarespace. To many, this strategic realignment came out of left field, providing a glaring clue about the shape of Google’s new vision. The seismic shift to prioritise artificial intelligence (AI) has raised questions about the fate of Firebase, a Google-owned platform popular among developers.
What will come of Firebase?
Under Sundar Pichai’s leadership, Google has transformed from a mobile-first to an AI-first company. If Google Domains, a more traditional web offering, no longer fits within the framework of this AI-focused vision, where does Firebase fit in?
In Aurelia 1, you could access the controller and ViewModel of an element using au.controller and in Aurelia 2, it’s more of the same (except the properties are different). Here is how you get the controller and ViewModel of an element in Aurelia 2.
import { Controller, ICustomElementViewModel } from "aurelia"; // Define an interface for Aurelia element export interface AuElement extends Element { $au: { "au:resource:custom-element": Controller; }; } /\*\* \* This function receives an element and extracts the Aurelia controller associated with it. \* @param {Element} element - The target element \* @returns {Controller|null} - The controller or null if it does not exist \*/ export function getElementController(element: Element): Controller | null { const auElement = element as AuElement; if (!auElement.$au) { return null; } return auElement.$au['au:resource:custom-element']; } /\*\* \* This function gets the View Model associated with a given element. \* @param {Element} element - The target element \* @returns {T|null} - The View Model or null if it does not exist \*/ export function getElementViewModel(element: Element): T | null { const controller = getElementController(element); return controller ? controller.viewModel as T : null; }
Recently while using the Material Components Web components in an Aurelia 2 application with Sass, I encountered an annoying issue where a warning would appear in my app. The warning appears to be harmless, but it’s annoying.
The error appears as:
Module Warning (from ./node_modules/sass-loader/dist/cjs.js): both $level and $color are required; received $level: ‘0’, $color: "
To fix it in Webpack, you can use the warningsFilter argument for stats to filter it out: