When working on a PHP codebase, one thing I really miss from the Typescript world is the ability to pass properly typed objects and array into functions.
I recently refactored an Ionic Angular app that previously made use of jQuery to fetch data and update the view 😔. Having moved the API calls into dedicated services, all API requests were blocked by the browser given the different origins (localhost vs external api url).
Here’s how to dynamically create a
div, set it’s
id property, and append it to the
body element in an Angular service or component. I’ll use the example of creating a recaptcha container div on the fly.
If you want to pass additional parameters to an Angular service, what you are looking for is @Inject decorator. It helps you pass your parameters to the service through Angular’s dependency injection mechanism.
I’ll start by saying YAML is awesome! It’s like that thing you’ve been looking for but never knew existed, at least for my use case.
The past couple of weeks I’ve been adding new functionality to an API and today began updating the Angular front-end application to reflect these changes.
So I’ve been working with Akveo’s Nebular UI Kit for a while now and it’s been a real issue adding custom content to
While using the Twitter web app, I noticed it displays a
Try Again button for failed requests in different sections of the user interface. This allows the user retry each failed request without affecting the rest of the application, quite neat.
Wouldn’t it be great if instead of doing
ng serve --proxy-config proxy.conf.js you simply use
ng serve and the Angular CLI takes care of the proxy redirect command? Well, you can.
I’ve had this longstanding issue with setting the size of modals created with NbDialogService.
To test your Angular build locally:
There are many articles on the web showing various methods of getting a reference to the window object in Angular (primarily through the dependency injection mechanism). However those that are popular on Google search are from 2016, 2017, etc, and the methods are mostly overly complicated (understandably).
Lately i’ve been trying to apply the concept of using the url as the single source of truth in Angular applications I work on. Today I wrote some functionality that demonstrates this quite well.
<time [dateTime]="'2019-08-09 16:22:20'">8/9/2019</time>
A few days back while looking into strongly typing reactive forms in Angular, I came across this post by Alex Klaus. Given reactive forms don’t currently support strong typing (see issues #13721 and #17000), he suggests making use of Daniele Morosinotto solution which involves leveraging Typescript declaration files (
Ever had this issue where for some reason you can’t navigate to a route even though everything seems ok, and the route’s data resolvers are all executing?
This assumes you’ve already setup API authentication in your Laravel application.
From the agGrid documentation,
FYI, this is a to the point guide on adding and Bootstrap 4 styles (scss) to an Angular project.
I may flesh this out with a detailed post later, but if you have any questions or encounter any issues feel free to reach out to me.
This little utility function can help you easily determine if a url string contains a protocol and add one if missing.
Say you have an object you’d like to conditionally add a member to, here’s a neat little trick to do it with the spread operator.
I’ve spent a few hours trying to get fragment navigation working properly for a use case on Xamcademy (https://xamcademy.com).
A few months back while working on a location based taxi calling app, I had to build in functionality to render the route from the user’s location to the selected or searched listing on the map.
trackBy is a function which will return a unique identifier for each item in the array provided to *ngFor.
Normally when the array changes, Angular re-renders the whole DOM tree. But if you use trackBy, Angular will know which element has changed and will only make DOM changes for that particular element.
Having created a good number of custom form controls in Angular, it always felt repetitive implementing the ControlValueAccessor interface in each custom component.