{"id":3843,"date":"2023-12-05T11:13:04","date_gmt":"2023-12-05T10:13:04","guid":{"rendered":"https:\/\/www.capri-soft.de\/blog\/?p=3843"},"modified":"2023-12-05T13:16:49","modified_gmt":"2023-12-05T12:16:49","slug":"angularjs-nodejs-schulung","status":"publish","type":"post","link":"https:\/\/www.capri-soft.de\/blog\/?p=3843","title":{"rendered":"AngularJS + NodeJS Schulung"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Vorraussetzung<\/h2>\n\n\n\n<p>Installation der folgenden Komponenten:<\/p>\n\n\n\n<p>NodeJS<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Konsolenbefehle<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm init -y \/\/ erstellt die package.json und best\u00e4tigt alles mit y\nnpm install typescript --save-dev \/\/ Mit Typescript entwickeln - f\u00fcgt in package.json eine devDependencies hinzu\nnpx tsc --init \/\/ Erzeugt tsconfig.json (enth\u00e4lt z.B. die Ecma-Script-Version)\nnpx tsc --watch \/\/ Schaut nach \u00c4nderungen\nnode src\/hello.js \/\/ Interpretiert das Javascript damit wir keinen Browser brauchen mit Node kann man aufs Dateisystem zugreifen\nnpm installiert pakete\nnpx tempor\u00e4res Paket\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Aufgabe 1: Klassen &amp; Methoden<\/h2>\n\n\n\n<p>Baue eine Klasse die etwas zur\u00fcckgibt bei folgendem Code<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nlet s: Student = new Student();\nlet label:string = s.getLabel(123457);\nconsole.log(label); \/\/ &quot;Student mit Matrikelnummer: 123456&quot;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">L\u00f6sung 1<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclass Student {\n    oldNumber:number = -1;\n\n    getLabel(matNr:number):string {\n        if (matNr == 123456)\n        {\n            this.oldNumber = matNr;\n            let zusammenGebaut = &quot;Die Nr. &quot; + this.oldNumber;\n            return zusammenGebaut;\n        }\n        else\n        {\n            return `Student mit Matrikelnummer: ${matNr}`;\n        }\n    }\n  }\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Aufgabe 2: Konstrukturen<\/h2>\n\n\n\n<p>Sorge daf\u00fcr, dass diese Ausgabe \u00fcber einen Konstruktor funktioniert<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nlet s: Student = new Student(&quot;Max&quot;, 123456);\nlet label: string = s.getLabel();\nconsole.log(label); \/\/ &quot;Student Max mit Matrikelnummer: 123456&quot;;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">L\u00f6sung 2<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nclass Student {\n    name: string;\n    mNr: number;\n\n    constructor(_name: string, _mNr: number) {\n      this.name = _name;\n      this.mNr = _mNr;\n    }\n\n    getLabel() {\n        return `Student ${this.name} mit Matrikelnummer ${this.mNr}`;\n    }\n  }\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Aufgabe 3: Auslagern in andere Dateien<\/h2>\n\n\n\n<p>Lagere die Klasse Student in eine andere Datei aus, so dass sie mit den folgenden Kommandos wieder instanziert werden kann<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nimport {Student} from &quot;.\/student&quot;\n\nlet s: Student = new Student(&quot;Max&quot;, 123456);\nlet label: string = s.getLabel();\nconsole.log(label); \/\/ &quot;Student Max mit Matrikelnummer: 123456&quot;;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">L\u00f6sung 3<\/h2>\n\n\n\n<p>Lege die Klasse student.js im gleichen Verzeichnis wie hello.js an und kopiere die Student-Klasse von L\u00f6sung 2 rein:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nexport class Student {\n    oldNumber:number = -1;\n    name: string;\n    mNr: number;\n\n    constructor(_name: string, _mNr: number) {\n      this.name = _name;\n      this.mNr = _mNr;\n    }\n\n    getLabel() {\n        return `Student ${this.name} mit Matrikelnummer ${this.mNr}`;\n    }\n  }\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Aufgabe 4: ESLint f\u00fcr sauberen Code<\/h2>\n\n\n\n<p>S\u00e4ubere den Code mit ESLint<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ansatz 4<\/h2>\n\n\n\n<p>F\u00fchre die folgenden Konsolenbefehle aus um ESLint zu verwenden:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm init @eslint\/config\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"160\" data-attachment-id=\"3857\" data-permalink=\"https:\/\/www.capri-soft.de\/blog\/?attachment_id=3857\" data-orig-file=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image.png?fit=624%2C211&amp;ssl=1\" data-orig-size=\"624,211\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image.png?fit=474%2C160&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image.png?resize=474%2C160&#038;ssl=1\" alt=\"\" class=\"wp-image-3857\" srcset=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image.png?w=624&amp;ssl=1 624w, https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image.png?resize=300%2C101&amp;ssl=1 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpx eslint src\/hello.ts\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Beobachtung 4<\/h2>\n\n\n\n<p>ESLint meckert:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"78\" data-attachment-id=\"3858\" data-permalink=\"https:\/\/www.capri-soft.de\/blog\/?attachment_id=3858\" data-orig-file=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?fit=660%2C109&amp;ssl=1\" data-orig-size=\"660,109\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?fit=474%2C78&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?resize=474%2C78&#038;ssl=1\" alt=\"\" class=\"wp-image-3858\" srcset=\"https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?w=660&amp;ssl=1 660w, https:\/\/i0.wp.com\/www.capri-soft.de\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?resize=300%2C50&amp;ssl=1 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">L\u00f6sung 4<\/h2>\n\n\n\n<p>\u00c4ndere den Code so, dass aus den Variablen aus L\u00f6sung 3 anstelle von <strong>let<\/strong> das Keyword <strong>const <\/strong>verwendet wird:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nimport {Student} from &quot;.\/student&quot;\n\nconst s: Student = new Student(&quot;Max&quot;, 123456);\nconst label: string = s.getLabel();\nconsole.log(label); \/\/ &quot;Student Max mit Matrikelnummer: 123456&quot;;\n<\/pre><\/div><iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.capri-soft.de%2Fblog%2F%3Fp%3D3843&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px;margin-top:5px;\"><\/iframe>","protected":false},"excerpt":{"rendered":"<p>Vorraussetzung Installation der folgenden Komponenten: NodeJS Konsolenbefehle Aufgabe 1: Klassen &amp; Methoden Baue eine Klasse die etwas zur\u00fcckgibt bei folgendem Code L\u00f6sung 1 Aufgabe 2: Konstrukturen Sorge daf\u00fcr, dass diese Ausgabe \u00fcber einen Konstruktor funktioniert L\u00f6sung 2 Aufgabe 3: Auslagern in andere Dateien Lagere die Klasse Student in eine andere Datei aus, so dass sie &hellip; <a href=\"https:\/\/www.capri-soft.de\/blog\/?p=3843\" class=\"more-link\"><span class=\"screen-reader-text\">AngularJS + NodeJS Schulung<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[447,14,30],"tags":[441,444,443,445,446],"class_list":["post-3843","post","type-post","status-publish","format-standard","hentry","category-angular-typescript-nodejs","category-htmlcss","category-javascript","tag-angular","tag-node","tag-nodejs","tag-schulung","tag-training"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4yGeN-ZZ","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3843"}],"version-history":[{"count":12,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3843\/revisions"}],"predecessor-version":[{"id":3860,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3843\/revisions\/3860"}],"wp:attachment":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}