{"id":1869,"date":"2023-12-11T05:00:00","date_gmt":"2023-12-11T13:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=1869"},"modified":"2023-12-08T15:29:10","modified_gmt":"2023-12-08T23:29:10","slug":"code-challenge-2-di-or-not-di","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/code-challenge-2-di-or-not-di\/","title":{"rendered":"Code challenge #2: DI or not DI?"},"content":{"rendered":"\n<p>One of the cool things about <a href=\"https:\/\/angulartraining.com\/\" target=\"_blank\" rel=\"noopener\" title=\"\">teaching Angular<\/a>, running an <a href=\"https:\/\/angulartraining.com\/angular-certification.html\" target=\"_blank\" rel=\"noopener\" title=\"\">Angular certification program<\/a>, and interacting with hundreds of developers (and code bases) all around the world is that I get to see a lot of good ideas but also a lot of repeated mistakes.<\/p>\n\n\n\n<p>Today, I want to share a small code challenge inspired by mistakes seen over the past few weeks so you can learn from these examples and hopefully won\u2019t make these same mistakes in the future.<\/p>\n\n\n\n<p>Here is the code I want you to look at: <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"694\" height=\"539\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-9.png\" alt=\"\" class=\"wp-image-1870\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-9.png 694w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/12\/image-9-300x233.png 300w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>You can <a href=\"https:\/\/stackblitz.com\/edit\/at-code-challenge-2?description=An%20angular-cli%20project%20based%20on%20@angular\/animations,%20@angular\/common,%20@angular\/compiler,%20@angular\/core,%20@angular\/forms,%20@angular\/platform-browser,%20@angular\/platform-browser-dynamic,%20@angular\/router,%20core-js,%20rxjs,%20tslib%20and%20zone.js&amp;file=src%2Fmain.ts,src%2Fdata.service.ts&amp;title=Angular%20Starter\" target=\"_blank\" rel=\"noopener\" title=\"\">run it on Stackblitz here<\/a> and fork the project to debug what&#8217;s wrong and make it work. Currently, this App component displays nothing at all, which is a problem. <\/p>\n\n\n\n<p>I\u2019ll give you a possible solution tomorrow. In the meantime, feel free to send me your solution if you want.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the cool things about teaching Angular, running an Angular certification program, and interacting with hundreds of developers (and code bases) all around the world is that I get to see a lot of good ideas but also a lot of repeated mistakes. Today, I want to share a small code challenge inspired by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,40],"tags":[],"class_list":["post-1869","post","type-post","status-publish","format-standard","hentry","category-angular","category-code-challenge"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=1869"}],"version-history":[{"count":1,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1869\/revisions"}],"predecessor-version":[{"id":1871,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1869\/revisions\/1871"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=1869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=1869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=1869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}