Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Tech News - Web Development

354 Articles
article-image-exploring%e2%80%afforms-in-angular-types-benefits-and-differences%e2%80%af%e2%80%af%e2%80%af-%e2%80%af
Expert Network
21 Jul 2021
11 min read
Save for later

Exploring Forms in Angular – types, benefits and differences     

Expert Network
21 Jul 2021
11 min read
While developing a web application, or setting dynamic pages and meta tags we need to deal with multiple input elements and value types, such limitations could seriously hinder our work – in terms of either data flow control, data validation, or user experience.    This article is an excerpt from the book, ASP.NET Core 5 and Angular, Fourth Edition by Valerio De Sanctis – A revised edition of a bestseller that includes coverage of the Angular routing module, expanded discussion on the Angular CLI, and detailed instructions for deploying apps on Azure, as well as both Windows and Linux.   Sure, we could easily work around most of the issues by implementing some custom methods within our form-based components; we could throw some errors such as isValid(), isNumber(), and so on here and there, and then hook them up to our template syntax and show/hide the validation messages with the help of structural directives such as *ngIf, *ngFor, and the like. However, it would be a horrible way to address our problem; we didn't choose a feature-rich client-side framework such as Angular to work that way.   Luckily enough, we have no reason to do that since Angular provides us with a couple of alternative strategies to deal with these common form-related scenarios:   Template-Driven Forms   Model-Driven Forms, also known as Reactive Forms   Both are highly coupled with the framework and thus extremely viable; they both belong to the @angular/forms library and share a common set of form control classes. However, they also have their own specific sets of features, along with their pros and cons, which could ultimately lead to us choosing one of them.   Let's try to quickly summarize these differences.   Template-Driven Forms   If you've come from AngularJS, there's a high chance that the Template-Driven approach will ring a bell or two. As the name implies, Template-Driven Forms host most of the logic in the template code; working with a Template-Driven Form means:   Building the form in the .html template file   Binding data to the various input fields using ngModel instance   Using a dedicated ngForm object related to the whole form and containing all the inputs, with each being accessible through their name.   These things need to be done to perform the required validity checks. To understand this, here's what a Template-Driven Form looks like:   <form novalidate autocomplete="off" #form="ngForm" (ngSubmit)="onSubmit(form)">  <input type="text" name="name" value="" required   placeholder="Insert the city name..."    [(ngModel)]="city.Name" #title="ngModel"   />  <span *ngIf="(name.touched || name.dirty) &&       name.errors?.required">           Name is a required field: please enter a valid city name.   </span>   <button type="submit" name="btnSubmit"          [disabled]="form.invalid">         Submit   </button>   </form>     Here, we can access any element, including the form itself, with some convenient aliases – the attributes with the # sign – and check for their current states to create our own validation workflow.   These states are provided by the framework and will change in real-time, depending on various things: touched, for example, becomes True when the control has been visited at least once; dirty, which is the opposite of pristine, means that the control value has changed, and so on. We used both touched and dirty in the preceding example because we want our validation message to only be shown if the user moves their focus to the <input name="name"> and then goes away, leaving it blank by either deleting its value or not setting it.   These are Template-Driven Forms in a nutshell; now that we've had an overall look at them, let's try to summarize the pros and cons of this approach. Here are the main advantages of Template-Driven Forms: Template-Driven Forms are very easy to write. We can recycle most of our HTML knowledge (assuming that we have any). On top of that, if we come from AngularJS, we already know how well we can make them work once we've mastered the technique.   They are rather easy to read and understand, at least from an HTML point of view; we have a plain, understandable HTML structure containing all the input fields and validators, one after another. Each element will have a name, a two-way binding with the underlying ngModel, and (possibly) Template-Driven logic built upon aliases that have been hooked to other elements that we can also see, or to the form itself.   Here are their weaknesses:   Template-Driven Forms require a lot of HTML code, which can be rather difficult to maintain and is generally more error-prone than pure TypeScript.   For the same reason, these forms cannot be unit tested. We have no way to test their validators or to ensure that the logic we implemented will work, other than running an end-to-end test with our browser, which is hardly ideal for complex forms.   Their readability will quickly drop as we add more and more validators and input tags. Keeping all their logic within the template might be fine for small forms, but it does not scale well when dealing with complex data items. Ultimately, we can say that Template-Driven Forms might be the way to go when we need to build small forms with simple data validation rules, where we can benefit more from their simplicity. On top of that, they are quite like the typical HTML code we're already used to (assuming that we do have a plain HTML development background); we just need to learn how to decorate the standard <form> and <input> elements with aliases and throw in some validators handled by structural directives such as the ones we've already seen, and we'll be set in (almost) no time.   For additional information on Template-Driven Forms, we highly recommend that you read the official Angular documentation at: https://angular.io/guide/forms   That being said; the lack of unit testing, the HTML code bloat that they will eventually produce, and the scaling difficulties will eventually lead us toward an alternative approach for any non-trivial form. Model-Driven/Reactive Forms   The Model-Driven approach was specifically added in Angular 2+ to address the known limitations of Template-Driven Forms. The forms that are implemented with this alternative method are known as Model-Driven Forms or Reactive Forms, which are the exact same thing.   The main difference here is that (almost) nothing happens in the template, which acts as a mere reference to a more complex TypeScript object that gets defined, instantiated, and configured programmatically within the component class: the form model.   To understand the overall concept, let's try to rewrite the previous form in a Model-Driven/Reactive way (the relevant parts are highlighted). The outcome of doing this is as follows:  <form [formGroup]="form" (ngSubmit)="onSubmit()">  <input formControlName="name" required />   <span *ngIf="(form.get('name').touched || form.get('name').dirty)            && form.get('name').errors?.required">           Name is a required field: please enter a valid city name.   </span>  <button type="submit" name="btnSubmit"           [disabled]="form.invalid">  Submit  </button>     </form>  As we can see, the amount of required code is much lower.  Here's the underlying form model that we will define in the component class file (the relevant parts are highlighted in the following code):   import { FormGroup, FormControl } from '@angular/forms';   class ModelFormComponent implements OnInit {   form: FormGroup;         ngOnInit() {       this.form = new FormGroup({          title: new FormControl()       });     }   }   Let's try to understand what's happening here:   The form property is an instance of FormGroup and represents the form itself.   FormGroup, as the name suggests, is a container of form controls sharing the same purpose. As we can see, the form itself acts as a FormGroup, which means that we can nest FormGroup objects inside other FormGroup objects (we didn't do that in our sample, though).   Each data input element in the form template – in the preceding code, name – is represented by an instance of FormControl.   Each FormControl instance encapsulates the related control's current state, such as valid, invalid, touched, and dirty, including its actual value.   Each FormGroup instance encapsulates the state of each child control, meaning that it will only be valid if/when all its children are also valid.   Also, note that we have no way of accessing the FormControls directly like we were doing in Template-Driven Forms; we have to retrieve them using the .get() method of the main FormGroup, which is the form itself.   At first glance, the Model-Driven template doesn't seem too different from the Template-Driven one; we still have a <form> element, an <input> element hooked to a <span> validator, and a submit button; on top of that, checking the state of the input elements takes a bigger amount of source code since they have no aliases we can use. What's the real deal, then?  To help us visualize the difference, let's look at the following diagrams: here's a schema depicting how Template-Driven Forms work:   [caption id="attachment_72453" align="alignnone" width="690"] Fig 1: Template-Driven Forms schematic[/caption] By looking at the arrows, we can easily see that, in Template-Driven Forms, everything happens in the template; the HTML form elements are directly bound to the DataModel component represented by a property filled with an asynchronous HTML request to the Web Server, much like we did with our cities and country table.   That DataModel will be updated as soon as the user changes something, that is, unless a validator prevents them from doing that. If we think about it, we can easily understand how there isn't a single part of the whole workflow that happens to be under our control; Angular handles everything by itself using the information in the data bindings defined within our template.   This is what Template-Driven actually means: the template is calling the shots.  Now, let's take a look at the Model-Driven Forms (or Reactive Forms) approach:   [caption id="attachment_72454" align="alignnone" width="676"] Fig 2: Model-Driven/Reactive Forms schematic[/caption] As we can see, the arrows depicting the Model-Driven Forms workflow tell a whole different story. They show how the data flows between the DataModel component – which we get from the Web Server – and a UI-oriented form model that retains the states and the values of the HTML form (and its children input elements) that are presented to the user. This means that we'll be able to get in-between the data and the form control objects and perform a number of tasks firsthand: push and pull data, detect and react to user changes, implement our own validation logic, perform unit tests, and so on.  Instead of being superseded by a template that's not under our control, we can track and influence the workflow programmatically, since the form model that calls the shots is also a TypeScript class; that's what Model-Driven Forms are about. This also explains why they are also called Reactive Forms – an explicit reference to the Reactive programming style that favors explicit data handling and change management throughout the workflow.   Summary    In this article, we focused on the Angular framework and the two form design models it offers: the Template-Driven approach, mostly inherited from AngularJS, and the Model-Driven or Reactive alternative. We took some valuable time to analyze the pros and cons provided by both, and then we made a detailed comparison of the underlying logic and workflow. At the end of the day, we chose the Reactive way, as it gives the developer more control and enforces a more consistent separation of duties between the Data Model and the Form Model.   About the author   Valerio De Sanctis is a skilled IT professional with 20 years of experience in lead programming, web-based development, and project management using ASP.NET, PHP, Java, and JavaScript-based frameworks. He held senior positions at a range of financial and insurance companies, most recently serving as Chief Technology and Security Officer at a leading IT service provider for top-tier insurance groups. He is an active member of the Stack Exchange Network, providing advice and tips on the Stack Overflow, ServerFault, and SuperUser communities; he is also a Microsoft Most Valuable Professional (MVP) for Developer Technologies. He's the founder and owner of Ryadel and the author of many best-selling books on back-end and front-end web development.      
Read more
  • 0
  • 0
  • 10884

article-image-giving-material-angular-io-a-refresh-from-angular-blog-medium
Matthew Emerick
07 Oct 2020
3 min read
Save for later

Giving material.angular.io a refresh from Angular Blog - Medium

Matthew Emerick
07 Oct 2020
3 min read
Hi everyone, I’m Annie and I recently joined the Angular Components team after finishing up my rotations as an Engineering Resident here at Google. During the first rotation of my residency I worked on the Closure Compiler and implemented some new ES2020 features including nullish coalesce and optional chaining. After that, my second rotation project was with the Angular Components where I took on giving material.angular.io a long awaited face lift. If you have recently visited the Angular Materials documentation site you will have noticed some new visual updates. We’ve included new vibrant images on the components page, updates to the homepage, a guides page revamp and so much more! Today I would like to highlight how we generated these fun colorful images. We were inspired by the illustrations on the Material Design components page which had aesthetic abstract designs that represented each component. We wanted to adapt the idea for material.angular.io but had some constraints and requirements to consider. First of all, we didn’t have a dedicated illustrator or designer for the project because of the tight deadline of my residency. Second of all, we wanted the images to be compact but clearly showcase each component and its usage. Finally, we wanted to be able to update these images easily when a component’s appearance changed. For the team the choice became clear: we’re going to need to build something ourselves to solve for these requirements. While weighing our design options, we decided that we preferred a more realistic view of the components instead of abstract representations. This is where we came up with the idea of creating “scenes” for each component and capturing them as they would appear in use. We needed a way to efficiently capture these components. We turned to a technique called screenshot testing. Screenshot testing is a technique that captures an image of the page of the provided url and compares it to an expected image. Using this technique we were able to generate the scenes for all 35 components. Here’s how we did it: Set up a route for each component that contains a “scene” using the actual material component Create an end-to-end testing environment and take screenshots of each route with protractor Save the screenshots instead of comparing them to an expected image Load the screenshots from the site One of the benefits of our approach is that whenever we update a component, we can just take new screenshots. This process saves incredible amounts of time and effort. To create each of the scenes we held a mini hackathon to come up with fun ideas! For example, for the button component (top) we wanted to showcase all the different types and styles of buttons available (icon, FAB, raised, etc.). For the button toggle component (bottom) we wanted to show the toggle in both states in a realistic scenario where someone might use a button toggle. Conclusion It was really exciting to see the new site go live with all the changes we made and we hope you enjoy them too! Be sure to check out the site and let us know what your favorite part is! Happy coding, friends! Giving material.angular.io a refresh was originally published in Angular Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Read more
  • 0
  • 0
  • 3974

article-image-react-newsletter-232-from-ui-devs-rss-feed
Matthew Emerick
29 Sep 2020
3 min read
Save for later

React Newsletter #232 from ui.dev's RSS Feed

Matthew Emerick
29 Sep 2020
3 min read
News Airbnb releases visx 1.0 This is a collection of reusable, low-level visualization components that combine the powers of D3 and React. It has been used internally at Airbnb for the last 2.5 years and was publicly released last week. We wrote a lot about it in yesterday’s issue of Bytes, if you’d like a longer, more colorful breakdown. Dan Abramov tweets about the future of import React tl;dr, eventually (like, a long eventually), stop using import React from 'react' and start using import * as React from 'react'. Articles Introducing the new JSX Transform This article from the official React Blog describes how React 17 provides support for a new version of JSX Transform. It goes over exactly what that new version is and how to try it out. The Complete Guide to Next.js Authentication In this comprehensive guide, Nader Dabit will teach you how to implement authentication in a Next.js app. It covers client authentication, authenticated server-rendered pages, authenticated API routes, protected routes, and redirects. Understanding React rendering Rendering is the most important procedure that a programmer has to manage in frontend development. In React, the render() method is the only required method in a class component and is responsible for describing the view to be rendered to the browser window. This article will help you understand the subtleties of how this method works. Tutorials Building a Material UI Dashboard with React In this tutorial, you’ll learn how to build a full-stack dashboard with KPIs, charts, and a data table. It takes you from data in the database to the interactive, filterable, and searchable admin dashboard. Building Multistep Forms with MaterialUI and React Hooks This tutorial walks you through how to use the React useState hook and the MaterialUI component library to build a multistep medical history collection form. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects Vime An open-source media player that’s customizable, extensible, and framework-agnostic. It also comes with bindings for React and other frameworks. headlessui-react A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS. Created by Tailwind Labs. reactivue Use the Vue Composition API in React components. Videos I built a chat app in 7 minutes with React & Firebase This video from Fireship demonstrates how quickly React and Firebase can help you to build simple apps like this chat app. Jeff is also maybe showing off just a little bit here, but we’re ok with that too.
Read more
  • 0
  • 0
  • 2977

article-image-react-in-the-streets-d3-in-the-sheets-from-ui-devs-rss-feed
Matthew Emerick
28 Sep 2020
6 min read
Save for later

React in the streets, D3 in the sheets from ui.dev's RSS Feed

Matthew Emerick
28 Sep 2020
6 min read
Got a real spicy one for you today. Airbnb releases visx, Elder.js is a new Svelte framework, and CGId buttholes. Airbnb releases visx 1.0 Visualizing a future where we can stay in Airbnbs again Tony Robbins taught us to visualize success… Last week, Airbnb officially released visx 1.0, a collection of reusable, low-level visualization components that combine the powers of React and D3 (the JavaScript library, not, sadly, the Mighty Ducks). Airbnb has been using visx internally for over two years to “unify our visualization stack across the company.” By “visualization stack”, they definitely mean “all of our random charts and graphs”, but that shouldn’t stop you from listing yourself as a full-stack visualization engineer once you’ve played around with visx a few times. Why tho? The main sales pitch for visx is that it’s low-level enough to be powerful but high-level enough to, well, be useful. The way it does this is by leveraging React for the UI layer and D3 for the under the hood mathy stuff. Said differently - React in the streets, D3 in the sheets. The library itself features 30 separate packages of React visualization primitives and offers 3 main advantages compared to other visualization libraries: Smaller bundles: because visx is split into multiple packages. BYOL: Like your boyfriend around Dinner time, visx is intentionally unopinionated. Use any animation library, state management solution, or CSS-in-JS tools you want - visx DGAF. Not a charting library: visx wants to teach you how to fish, not catch a fish for you. It’s designed to be built on top of. The bottom line Are data visualizations the hottest thing to work on? Not really. But are they important? Also not really. But the marketing and biz dev people at your company love them. And those nerds esteemed colleagues will probably force you to help them create some visualizations in the future (if they haven’t already). visx seems like a great way to help you pump those out faster, easier, and with greater design consistency. Plus, there’s always a chance that the product you’re working on could require some sort of visualizations (i.e. tooltips, gradients, patterns, etc.). visx can help with that too. So, thanks Airbnb. No word yet on if Airbnb is planning on charging their usual 3% service fee on top of an overinflated cleaning fee for usage of visx, but we’ll keep you update. Elder.js 1.0 - a new Svelte framework Whoever Svelte it, dealt it dear Respect your generators… Elder.js 1.0 is a new, opinionated Svelte framework and static site generator that is very SEO-focused. It was created by Nick Reese in order to try and solve some of the unique challenges that come with building flagship SEO sites with 10-100k+ pages, like his site elderguide.com. Quick Svelte review: Svelte is a JavaScript library way of life that was first released ~4 years ago. It compiles all your code to vanilla JS at build time with less dependencies and no virtual DOM, and its syntax is known for being pretty simple and readable. So, what’s unique about Elder.js? Partial hydration: It hydrates just the parts of the client that need to be interactive, allowing you to significantly reduce your payloads and still maintain full control over component lazy-loading, preloading, and eager-loading. Hooks, shortcodes, and plugins: You can customize the framework with hooks that are designed to be “modular, sharable, and easily bundled in to Elder.js plugins for common use cases.” Straightforward data flow: Associating a data function in your route.js gives you complete control over how you fetch, prepare, and manipulate data before sending it to your Svelte template. These features (plus its tiny bundle sizes) should make a Elder.js a faster and simpler alternative to Sapper (the default Svelte framework) for a lot of use cases. Sapper is still probably the way to go if you’re building a full-fledged Svelte app, but Elder.js seems pretty awesome for content-heavy Svelte sites. The bottom line We’re super interested in who will lead Elder.js’s $10 million seed round. That’s how this works, right? JS Quiz - Answer Below Why does this code work? const friends = ['Alex', 'AB', 'Mikenzi'] friends.hasOwnProperty('push') // false Specifically, why does friends.hasOwnProperty('push') work even though friends doesn’t have a hasOwnProperty property and neither does Array.prototype? Cool bits Vime is an open-source media player that’s customizable, extensible, and framework-agnostic. The React Core Team wrote about the new JSX transform in React 17. Speaking of React 17, Happy 3rd Birthday React 16 😅. Nathan wrote an in-depth post about how to understand React rendering. Urlcat is a cool JavaScript library that helps you build URLs faster and avoid common mistakes. Is it cooler than the live-action CATS movie tho? Only one of those has CGId buttholes, so you tell us. (My search history is getting real weird writing this newsletter.) Everyone’s favorite Googler Addy Osmani wrote about visualizing data structures using the VSCode Debug Visualizer. Smolpxl is a JavaScript library for creating retro, pixelated games. There’s some strong Miniclip-in-2006 vibes in this one. Lea Verou wrote a great article about the failed promise of Web Components. “The failed promise” sounds like a mix between a T-Swift song and one of my middle school journal entries, but sometimes web development requires strong language, ok? Billboard.js released v2.1 because I guess this is now Chart Library Week 2020. JS Quiz - Answer const friends = ['Alex', 'AB', 'Mikenzi'] friends.hasOwnProperty('push') // false As mentioned earlier, if you look at Array.prototype, it doesn’t have a hasOwnProperty method. How then, does the friends array have access to hasOwnProperty? The reason is because the Array class extends the Object class. So when the JavaScript interpreter sees that friends doesn’t have a hasOwnProperty property, it checks if Array.prototype does. When Array.prototype doesn’t, it checks if Object.prototype does, it does, then it invokes it. const friends = ['Alex', 'AB', 'Mikenzi'] console.log(Object.prototype) /* constructor: ƒ Object() hasOwnProperty: ƒ hasOwnProperty() isPrototypeOf: ƒ isPrototypeOf() propertyIsEnumerable: ƒ propertyIsEnumerable() toLocaleString: ƒ toLocaleString() toString: ƒ toString() valueOf: ƒ valueOf() */ friends instanceof Array // true friends instanceof Object // true friends.hasOwnProperty('push') // false
Read more
  • 0
  • 0
  • 3143

article-image-react-newsletter-231-from-ui-devs-rss-feed
Matthew Emerick
22 Sep 2020
2 min read
Save for later

React Newsletter #231 from ui.dev's RSS Feed

Matthew Emerick
22 Sep 2020
2 min read
Articles Guidelines to improve your React folder structure In this article, Max Rosen starts of by showing you his typical folder structure, then teaches you his guiding principles to create the folder structure that “feels right,” at least for his purposes. How to make your react-native project work for the web React-native-web should (in theory) allow you to build on both mobile and web platforms — all within a single codebase. In this article, Clint walks through building a very basic app and the tips and tricks he learned along the way to help it perform at high level without being too buggy. Why Next.js my ultimate choice over Gatsby, Gridsome, and Nuxt? In this article, Ondrej walks through his process for evaluating each of these technologies and why he ultimately chose to go with Next.js. Tutorials Building complex animations with React and Framer Motion This tutorial walks you through how to create smooth, advanced animations in React with clean and minimal declarative code. Building React Apps With Storybook In this in-depth tutorial, you’ll learn how to build and test react components in isolation using Storybook. You will also learn how to use the knobs add-on to modify data directly from the storybook explorer. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects SurveyJS A JavaScript survey and form library that also features a React version. react-range Range input with a slider. It’s accessible and lets you bring your own styles and markup. react-xr React components and hooks for creating VR/AR applications with react-three-fiber. Videos How To Build CodePen With React In this 30-minute video, you’ll learn how to create a simple clone of the core functionality of CodePen using React. Building a Netflix clone with React, Styled Components, and Firebase This 10-hour video (😱) walks you through all the steps of building a React clone from scratch.
Read more
  • 0
  • 0
  • 2099

article-image-angular-thoughts-on-docs-from-angular-blog-medium
Matthew Emerick
18 Sep 2020
5 min read
Save for later

Angular Thoughts on Docs from Angular Blog - Medium

Matthew Emerick
18 Sep 2020
5 min read
Photo by Patrick Tomasso on Unsplash If you have visited the docs at angular.io lately, you might have noticed some changes in our content layout and structure. As the lead technical writer for Angular, I thought I’d take a moment to cover some of the main goals we have for making the Angular documentation experience the best experience possible. Focus on developers new to Angular A common pitfall for many documentation sets is that they address too many audiences at once. This practice results in content that is verbose, difficult to navigate, and frustrating to read. For Angular, it’s important that we focus on a single audience at a time, because we want to make sure to tell the right stories clearly and concisely. Right now, that means our documentation efforts focus on developers new to Angular. Since I joined the Angular team, I’ve heard a recurring theme: “Angular has a steep learning curve.” “The Angular documentation is overwhelming.” As someone new to Angular, I find myself agreeing with these sentiments. That’s why, for the next several months, we’re focusing on making the getting started experience the best experience possible. Some of the changes we’re making include: Revamping the table of contents (the lists of topics in the left navigation) to help users understand what main concepts of Angular they should understand, and what topics can wait until they want to expand their applications further. Categorizing topics into three topic types: Concepts, Tasks, and Tutorials. It’s important for any reader — whether they are new to Angular or not! — to know what kind of content they’re reading and whether it’s what they’re looking for. No one likes looking for how to get something done only to find themselves 3 paragraphs into a tutorial. Streamlining existing content. When I write, I imagine that I’m tutoring a friend who has a plane to catch in 5 minutes. This image helps me focus on content that is casual in tone, but also concise and to the point. Applying this idea to Angular documentation will help users find the information they need and get back to code. Help users get things done Developers need documentation for a lot of different reasons. Sometimes you need a basic walkthrough of the technology. Other times, you need a real-world tutorial that addresses a problem that you’re facing. Like focusing on a specific audience, a good documentation set focuses on one of these reasons at a time. For Angular, we’re focused on writing content that helps users get things done. When you navigate to the Angular documentation, we want you to find the information you need to complete a task or understand a feature, and then we want you to be able to get back to writing great code. To accomplish this goal, we’re going through all of the topics to make sure they clearly state what they cover and why that’s important. You should know right away if you’re reading the content you need. And if you’re not? We’re working on providing links to other topics that might be more helpful. Of course, there’s always a place for more conceptual content. And there’s a lot of great value in developing a deep understanding of how something works. I’m sure we’ll focus on improving our conceptual content at some point in the future. For the time being, however, we want to make sure that you can find the help you need quickly and easily. Improve, but don’t break As we mentioned earlier, many within the Angular community find the current documentation overwhelming. At the same time, we’ve also heard that the documentation remains one of the best places to learn how to build with Angular. That’s why one of the other key goals that we’re focusing on is to improve the documentation without breaking it. As we write new content or improve existing content, we try to make sure that the existing documentation remains intact. There are always going to be times where we might fall short on this goal. When that happens, please let us know by filing a GitHub issue so we can investigate. Conclusion We think that focusing on new Angular developers, writing content that helps you get things done, and making sure we improve the documentation without breaking it, will result in a better documentation experience for everyone. Of course, this is just the beginning. For example, as we wrap up content for new developers, we’ll start looking at other audiences, such as those of you working on enterprise-level applications. I can’t express how grateful I am to work on a product that has such a passionate, supportive community, and I look forward to working with all of you to make the Angular documentation the best experience possible. In the meantime, continue to check out the docs and don’t hesitate to let us know what you think! Angular Thoughts on Docs was originally published in Angular Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Read more
  • 0
  • 0
  • 2036
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime
article-image-react-newsletter-230-from-ui-devs-rss-feed
Matthew Emerick
15 Sep 2020
2 min read
Save for later

React Newsletter #230 from ui.dev's RSS Feed

Matthew Emerick
15 Sep 2020
2 min read
Articles Rewriting Facebook’s “Recoil” React library from scratch in 100 lines Bennett gives a great breakdown of Recoil by building a clone of it from scratch and discussing each of the components that go into it. React + TypeScript ❤️: The good parts ⚡ In this article, Diego writes about both the pros and cons of building with React and TypeScript and why he ultimately loves it. Tutorials Making Draggable Components in React This tutorial illustrates some simple ways to make draggable components in React using the react-draggable package. How to Use Redux in Your React TypeScript App This guide demonstrates how to use Redux in your React TypeScript project by building an app that allows you to add, delete, and show articles. It assumes some basic knowledge of TypeScript, React, and Redux, but is still pretty beginner-friendly. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects React Popup Component v2 A simple react popup component that help you create simple and complex Modals, tooltips, and menus for your next React App. Jotai A new, primitive, flexible state management library for React, from the creators of React Spring. New VSCode extension for React icons Allows you to search from 20+ free icon sets and directly add SVG or JSX into your code without leaving the editor. Turtle 🐢 A progressive web app built with React, Ionic, and Firebase that syncs videos so that you can have a socially-distanced watch party with friends Videos React in 100 seconds A great review of the history and fundamentals of React by Fireship.io. Building a Multiplayer Chess Game This 17-minute video walks through building a web app for multiplayer chess with React and Node.js. Serverless Video Chat App using Firebase and WebRTC in React This 55-minute video tutorials demonstrates how to build a video chat app and gives a helpful introduction to WebRTC.
Read more
  • 0
  • 0
  • 1746

article-image-angular-localization-with-ivy-from-angular-blog-medium
Matthew Emerick
09 Sep 2020
5 min read
Save for later

Angular localization with Ivy from Angular Blog - Medium

Matthew Emerick
09 Sep 2020
5 min read
Part of the new Angular rendering engine, Ivy, includes a new approach to localizing applications — specifically extracting and translating text. This article explains the benefits and some of the implementation of this new approach. Prior to Ivy, the only way to add localizable messages to an Angular application was to mark them in component templates using the i18n attribute: <div i18n>Hello, World!</div> The Angular compiler would replace this text when compiling the template with different text if a set of translations was provided in the compiler configuration. The i18n tags are very powerful — they can be used in attributes as well as content; they can include complex nested ICU (International Components for Unicode) expressions; they can have metadata attached to them. See our i18n guide for more information. But there were some shortcomings to this approach. The most significant concern was that translation had to happen during template compilation, which occurs right at the start of the build pipeline. The result of this is that that full build, compilation-bundling-minification-etc, had to happen for each locale that you wanted to support in your application. (build times will vary based on project size) If a single build took 3 minutes, then the total build time to support 9 locales would be 3 mins x 9 locales = 27 mins. Moreover, it was not possible to mark text in application code for translation, only text in component templates. This resulted in awkward workarounds where artificial components were created purely to hold text that would be translated. Finally, it was not possible to load translations at runtime, which meant it was not possible for applications to be provided to an end-user who might want to provide translations of their own, without having to build the application themselves. The new localization approach is based around the concept of tagging strings in code with a template literal tag handler called $localize. The idea is that strings that need to be translated are “marked” using this tag: const message = $localize `Hello, World!`; This $localize identifier can be a real function that can do the translation at runtime, in the browser. But, significantly, it is also a global identifier that survives minification. This means it can act simply as a marker in the code that a static post-processing tool can use to replace the original text with translated text before the code is deployed. For example, the following code: warning = $localize `${this.process} is not right`; could be replace with: warning = "" + this.process + ", ce n'est pas bon."; The result is that all references to $localize are removed, and there is zero runtime cost to rendering the translated text. The Angular template compiler, for Ivy, has been redesigned to generate $localize tagged strings rather than doing the translation itself. For example the following template: <h1 i18n>Hello, World!</h1> would be compiled to something like: ɵɵelementStart(0, "h1"); // <h1>ɵɵi18n(1, $localize`Hello, World!`); // Hello, World!ɵɵelementEnd(); // </h1> This means that after the Angular compiler has completed its work all the template text marked with i18n attributes have been converted to $localize tagged strings which can be processed just like any other tagged string. Notice also that the $localize tagged strings can occur in any code (user code or generated from templates in both applications or libraries) and are not affected by minification, so while the post-processing tool might receive code that looks like this ...var El,kl=n("Hfs6"),Sl=n.n(kl);El=$localize`Hello, World!`;let Cl=(()=>{class e{constructor(e)... it is still able to identify and translate the tagged message. The result is that we can reorder the build pipeline to do translation at the very end of the process, resulting in a considerable build time improvement. (build times will vary based on project size) Here you can see that the build time is still 3 minutes, but since the translation is done as a post-processing step, we only incur that build cost once. Also the post-processing of the translations is very fast since the tool only has to parse the code for $localize tagged strings. In this case around 5 seconds. The result is that the total build time for 9 locales is now 3 minutes + ( 9 x 5 seconds) = 3 minutes 45 seconds. Compared to 27 minutes for the pre-Ivy translated builds. Similar improvements have been seen in real life by teams already using this approach: The post-processing of translations is already built into the Angular CLI and if you have configured your projects according to our i18n guide you should already be benefitting from these faster build times. Currently the use of $localize in application code is not yet publicly supported or documented. We will be working on making this fully supported in the coming months. It requires new message extraction tooling — the current (pre-Ivy) message extractor does not find $localize text in application code. This is being integrated into the CLI now and should be released as part of 10.1.0. We are also looking into how we can better support translations in 3rd party libraries using this new approach. Since this would affect the Angular Package Format (APF) we expect to run a Request for Comment (RFC) before implementing that. In the meantime, enjoy the improved build times and keep an eye out for full support of application level localization of text. Angular localization with Ivy was originally published in Angular Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Read more
  • 0
  • 0
  • 2693

article-image-react-newsletter-229-from-ui-devs-rss-feed
Matthew Emerick
08 Sep 2020
2 min read
Save for later

React Newsletter #229 from ui.dev's RSS Feed

Matthew Emerick
08 Sep 2020
2 min read
Articles A Gentle Introduction to Code Splitting with React This article uses a real-word example of building a healthcare application to give a helpful introduction to code splitting. Examples of large production-grade, open-source React apps In this article, Max Rosen reviews a few large-scale, open-source React apps that you might want to check out. Converting the ReactJS.org documentation to use hooks Mark Stewart wrote about how and why he converted the ReactJS.org documentation to use functions and hooks, instead of class-based components. Tutorials Create a React App with TS, Redux and OAuth 2.0 - Spotify login example In this tutorial, you’ll create a React app using the official Redux + Typescript template and add OAuth 2.0 user authorization. The OAuth 2.0 authorization in this tutorial is used to connect to Spotify’s Web API, but can be used for any service with the same authorization flow. The web app created you’ll create is a stand-alone client-side web app with no server-side application needed. Build a TikTok Clone with React and Firebase In this tutorial you’ll use React, Firebase, and Material UI to create a TikTok clone. If your clone is good enough, maybe you’ll be able to convince millions of American teens to download it if/when the original TikTok gets banned 🙃. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects react-email-editor React Email Editor is a drag-n-drop email template builder component that makes it easy to add a solid email editor to your React apps. Designs are saved in JSON and can be exported as HTML. Spearmint A open-source tool to help React developers generate tests for a wide range of applications and technologies. Firetable An open-source, spreadsheet-like interface for Firebase/Firestore built in React. radioactive-state Radioactive state is a deeply reactive state. When it is mutated at any level (shallow or deep) it re-renders the component automatically.
Read more
  • 0
  • 0
  • 1662

article-image-summer-2020-internship-with-the-angular-team-from-angular-blog-medium
Matthew Emerick
02 Sep 2020
3 min read
Save for later

Summer 2020 Internship With the Angular Team from Angular Blog - Medium

Matthew Emerick
02 Sep 2020
3 min read
Photo by Emma Twersky TL;DR Our interns were phenomenal! Read on to find out why. We’ve just wrapped up our latest intern cohort on the Angular team. Please believe me when I tell you that there are some outstanding folks out there and we were lucky enough to get to work with a few of them. Because of the ongoing pandemic Google internships were fully remote. We’re fortunate to have had some really special folks because they were outstanding. Let’s take a look at the great work developed during this cohort on the Angular Team! Better Paths for Learners One of things we’re focused on with the team is making sure that the Angular learning journey works for experienced developers and new developers. Our wonderful intern on the DevRel team, Gloria, took this mission to heart. Gloria Nduka zeroed in on the friction of the learning path for new developers. She used those insights to not only help the team but also to create an interactive tutorial focused on helping developers new to Angular. The tutorial puts the output, code, and next steps in the same window allowing learners to reduce context switching. Gloria’s second project focused on reaching out to and partnering with computer science programs to expose more students to the platform. She was able to make some meaningful connections and we are excited to continue to this initiative. Seeing Opportunities in the CDK The Angular CDK is a wonderful resource aimed at abstracting common application behaviors and interactions. Andy Chrzaszcz saw an opportunity to add new functionality to menus and improve accessibility. He added some great new directives to the CDK that give developers an expressive way to build powerful menus for Angular apps! The foundation set via his contributions will give developers the ability to build all types of menus with advanced interactions like sub-menus, intelligent menu closing and more. Developers will be able to craft menus that meet the application’s needs. A Combination of Great Things Popping Up Presenting lists of data for user’s to select from is standard fare in web development. But how can the Angular CDK help with that? Niels Rasmussen gives us that answer with his project aimed at creating directives that provide a foundation for implementing complex combobox UI components. Because the goal of the Angular CDK is to provide common behaviors, Niels’s solution follows suit for the list box and combo box gives developers the freedom to customize the presentation of the UI to their specific use cases. This brings much welcomed flexibility into the fold. Thanks for Sharing Your Gifts With Us Finally, we want to send an enthusiastic thank you and good luck to all of our interns as they finish up their undergraduate programs. We’ve seen the future in you and things are looking incredibly bright. If you’d like to be an intern here at Google, we invite you to apply. The world needs your gifts and talents. These projects will be released in future versions of the platform. Stay tuned for updates. Summer 2020 Internship With the Angular Team was originally published in Angular Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Read more
  • 0
  • 0
  • 1907
article-image-react-newsletter-228-from-ui-devs-rss-feed
Matthew Emerick
01 Sep 2020
2 min read
Save for later

React Newsletter #228 from ui.dev's RSS Feed

Matthew Emerick
01 Sep 2020
2 min read
Articles React Component Patterns In this article, Alexi Taylor will help you to identify the trade-offs of the different React patterns and when each pattern would be most appropriate. These patterns will allow for more useful and reusable code by adhering to design principles like separation of concern, DRY, and code reuse. Each major pattern includes an example hosted on CodeSandBox. Redux vs React’s Context API For the last few years, Redux has been THE state management solution for bigger React apps. It’s far from being dead and yet, a strong enemy is arising: React’s Context API! In this article you’ll learn, What is Redux? What is React’s Context API? Will React’s Context API replace Redux? Tutorials Morphing SVG With react-spring In this tutorial, Mikael gives a helpful overview on how to add the popular morphing effect to an SVG using the react-spring animation library. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects Intro to Storybook Two Storybook maintainers just released this new collection of guides that walks through all of the new Storybook features, while still covering the fundamentals. Effectful JavaScript Debugger A new JavaScript/TypeScript debugger with hot-swapping, API & Persistent state, time traveling and more. Zustand A small, fast and scaleable state-management solution. It has a hooks-based api, isn’t boilerplate-y or opinionated, and is “just enough to be explicit and flux-like.” Videos Why Next.js is the future of React In this 10-minute video, Lee Robinson shares why he believes that Next.js will be the go-to way to build React applications in the future. Keep in mind that Lee is a Next.js maintainer, so he might be a little biased. 🙂 RN Casts A collection of bite-sized React and React Native videos that each cover one specific topic (i.e. Handling input events in React).
Read more
  • 0
  • 0
  • 1543

article-image-ionic-angular-powering-the-app-store-and-the-web-from-angular-blog-medium
Matthew Emerick
31 Aug 2020
5 min read
Save for later

Ionic + Angular: Powering the App store and the web from Angular Blog - Medium

Matthew Emerick
31 Aug 2020
5 min read
Did you know Ionic and Angular power roughly 10% of the apps on iOS and almost 20% of apps on Android? Let’s repeat that: Angular powers a significant chunk of apps in the app stores. Why is it helpful to know this? Well, if you were on the fence about what technology choice you should make for your next app, it should be reassuring to know that apps powered by web technology are thriving in the app store. Let’s explore how we came to that conclusion and why it matters. First, for a number of reasons, users visit these stores and download apps that help them in their day-to-day lives. Users are searching for ToDo apps (who doesn’t love a good ToDo app), banking apps, work-specific apps and so much more. A good portion of these apps are built using web technologies such as Ionic and Angular. But enough talk, let’s look at some numbers to back this up. The Data If you’ve never heard of Appfigures, it’s an analytics tool that monitors and offers insights on more than 150,000 apps. Appfigures provides some great insight into what kind of tools developers are using to build their apps. Like what’s the latest messaging, mapping, or development SDK? That last one is the most important metric we want to explore. Let’s look at what the top development SDKs are for app development: Data from https://appfigures.com/top-sdks/development/apps Woah, roughly 10% of the apps on iOS and almost 20% of apps on Android use Ionic and Angular. This is huge. The data here is gathered by analyzing the various SDKs used in apps on the app stores. In these charts we see some options that are to be expected like Swift and Kotlin. But Ionic and Angular are still highly present. We could even include Cordova, since many Ionic apps are Cordova-based, and these stats would increase even more. But we’ll keep to the data that we know for sure. Given the number of apps out there, even 10% and 20% are a significant size. If you ignore Appfigures, you can get a sense of how many Ionic/Angular apps are there by just searching for “com.ionicframework”, which is our starting package ID (also, people should really change this). Here’s a link if you’re interested. Why Angular for mobile? Developers are using Ionic and Angular power a good chunk of the app stores. With everything Angular has to offer in terms of developer experience, tooling for fast apps, and its ecosystem of third-party libraries (like Ionic), it’s no wonder developers choose it as their framework of choice. From solo devs, to small shops, to large organizations like the UK’s National Health Service, Boehringer Ingelheim and BlueCross Blue Shield, these organizations have selected Angular and Ionic for their tech stack, and you should feel confident to do so as well. Web vs. App Stores If Ionic and Angular are based on web technologies, why even target the app stores at all? With Progressive Web Apps gaining traction and the web becoming a more capable platform, why not just deploy to the web and skip the app stores? Well it turns out that the app stores provide a lot of value that products need. Features like Push Notifications, File System API, etc are starting to come to the web, but they are still not fully available in every browser. Building a hybrid app with Ionic and Angular can allow developers to use these features and gracefully fallback when these APIs are not available. Discoverability is also another big factor here. While we can search for anything on the web, having users discover your app can be challenging. With the app stores they regularly promote new apps and highly rated apps as well. This can make the difference between a successful product and one that fails. The Best of Both Worlds The web is still an important step to shipping a great app. But when developers want to target different platforms, having the right libraries in place can make all the difference. For instance, if you want to build a fast and performant web app, Angular is an excellent choice and is statistically the choice many developers make. On the other hand, if you want to bring that app experience to a mobile device, with full access to every native feature and offline capabilities, then a hybrid mobile app using Angular plus a mobile SDK like Ionic is the way to go. Either way, your investment in Angular will serve you well. And you’ll be in good company, with millions of devs and nearly a million apps right alongside you. Ionic + Angular: Powering the App store and the web was originally published in Angular Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Read more
  • 0
  • 0
  • 2070

article-image-react-newsletter-227-from-ui-devs-rss-feed
Matthew Emerick
25 Aug 2020
2 min read
Save for later

React Newsletter #227 from ui.dev's RSS Feed

Matthew Emerick
25 Aug 2020
2 min read
Articles Build A Confirmation Modal in React with State Machines In this article, Dave builds a reusable state machine using React and Robot to handle this modal confirmation flow, and wraps it up into a custom hook. Why the OKCupid team decided against using GraphQL for local state management The OKCupid team describes themselves as “pretty big fans of using GraphQL.” So why did they decide against using it for local state management? Read the article to find out. Introduction to props in React This one’s for the beginners. In this post you’ll learn how to properly use props to pass data to components in React. State of Frontend 2020 Survey results Some interesting results in the state of frontend 2020 survey, specifically around React, Redux, and Gatsby vs Next. Tutorials 8 ways to deploy a React app for free This tutorial demonstrates how to deploy a React application in eight different ways. All the services described in this post are completely free with no hidden credit card requirements. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects React + TypeScript Cheatsheets Cheatsheets for experienced React developers getting started with TypeScript react-colorful A tiny color picker component for modern React apps. Videos Fullstack React, GraphQL, TypeScript Tutorial In this 14-hour long video, Ben Awad walks you through building a fullstack React, GraphQL, TypeScript app. This tutorial is geared towards intermediate developers looking to get their feet wet with these technologies. Ionic Framework Horizontal & SideMenu Navigation in ReactJS Application This 8-minute video demonstrates how to use Window.matchMedia() to do media queries and get a result back, and based on that result to hide or show the side menu.
Read more
  • 0
  • 0
  • 1306
article-image-introduction-to-props-in-react-from-ui-devs-rss-feed
Matthew Emerick
21 Aug 2020
3 min read
Save for later

Introduction to props in React from ui.dev's RSS Feed

Matthew Emerick
21 Aug 2020
3 min read
Whenever you have a system that is reliant upon composition, it’s critical that each piece of that system has an interface for accepting data from outside of itself. You can see this clearly illustrated by looking at something you’re already familiar with, functions. function getProfilePic (username) { return 'https://photo.fb.com/' + username } function getProfileLink (username) { return 'https://www.fb.com/' + username } function getAvatarInfo (username) { return { pic: getProfilePic(username), link: getProfileLink(username) } } getAvatarInfo('tylermcginnis') We’ve seen this code before as our very soft introduction to function composition. Without the ability to pass data, in this case username, to each of our of functions, our composition would break down. Similarly, because React relies heavily on composition, there needs to exist a way to pass data into components. This brings us to our next important React concept, props. Props are to components what arguments are to functions. Again, the same intuition you have about functions and passing arguments to functions can be directly applied to components and passing props to components. There are two parts to understanding how props work. First is how to pass data into components, and second is accessing the data once it’s been passed in. Passing data to a component This one should feel natural because you’ve been doing something similar ever since you learned HTML. You pass data to a React component the same way you’d set an attribute on an HTML element. <img src='' /> <Hello name='Tyler' /> In the example above, we’re passing in a name prop to the Hello component. Accessing props Now the next question is, how do you access the props that are being passed to a component? In a class component, you can get access to props from the props key on the component’s instance (this). class Hello extends React.Component { render() { return ( <h1>Hello, {this.props.name}</h1> ) } } Each prop that is passed to a component is added as a key on this.props. If no props are passed to a component, this.props will be an empty object. class Hello extends React.Component { render() { return ( <h1>Hello, {this.props.first} {this.props.last}</h1> ) } } <Hello first='Tyler' last='McGinnis' /> It’s important to note that we’re not limited to what we can pass as props to components. Just like we can pass functions as arguments to other functions, we’re also able to pass components (or really anything we want) as props to other components. <Profile username='tylermcginnis' authed={true} logout={() => handleLogout()} header={<h1>👋</h1>} /> If you pass a prop without a value, that value will be set to true. These are equivalent. <Profile authed={true} /> <Profile authed />
Read more
  • 0
  • 0
  • 1333

article-image-react-newsletter-226-from-ui-devs-rss-feed
Matthew Emerick
18 Aug 2020
2 min read
Save for later

React Newsletter #226 from ui.dev's RSS Feed

Matthew Emerick
18 Aug 2020
2 min read
News Storybook 6.0 is released Storybook 6.0 is a lot easier to set up and also incorporates many best practices for component-drive development. Other highlights include: Zero-configuration setup Next-gen, dynamic story format Live edit component examples The ability to combine multiple story books Rome: A new toolchain for JavaScript Sebastian McKenzie announced Rome’s first beta release last week, and called it “the spiritual successor of Babel” (he’s allowed to say that because he created Babel). “Rome is designed to replace Babel, ESLint, webpack, Prettier, Jest, and others” We wrote more in depth about Rome in yesterday’s issue of Bytes. Articles Understanding React’s useRef Hook In this article you’ll learn everything you’d ever want to know about React’s useRef Hook including but not limited to how you can recreate it with useState - because, why not? A Guide to Commonly Used React Component Libraries This guide gives some helpful background info and the pros and cons of various well-known component libraries. Tutorials Build a Landing Page with Chakra UI - Part 1 This tutorial series will teach you how to build a responsive landing page in React using the Chakra UI design system. This first part goes over how to set up your landing page and build the hero section. How to setup HTTPS locally with create-react-app This tutorial goes over how to serve a local React app via HTTPS. You’ll be setting up HTTPS in development for a create-react-app with an SSL certificate. Sponsor React developers are in demand on Vettery Vettery is an online hiring marketplace that’s changing the way people hire and get hired. Ready for a bold career move? Make a free profile, name your salary, and connect with hiring managers from top employers today. Get started today. Projects Flume An open-source library that provides a node editor for visual programming and a runtime engine for executing logic in any JS environment (also portable to non-js). Vite + React + Tailwind CSS starter This is a simple setup using Vite, React and Tailwind for faster prototyping. Videos How the React Native Bridge works This short video from Jimmy Cook gives a helpful deep dive into the React Native bridge and how communication between the native side and the JavaScript side will change in the future.
Read more
  • 0
  • 0
  • 1239