Skip to content
Snippets Groups Projects
Commit 862fa58b authored by Tormod Nygård's avatar Tormod Nygård
Browse files

Issue: Added Shared module (#3)

parent 27399ae7
No related branches found
No related tags found
1 merge request!3Resolve "Frontend: Annonser form"
Showing
with 72 additions and 8 deletions
......@@ -5,6 +5,7 @@ import { HttpClientModule } from '@angular/common/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { PostModule } from './posts/post.module';
import { SharedModule } from './shared/shared.module';
@NgModule({
declarations: [
......@@ -14,6 +15,7 @@ import { PostModule } from './posts/post.module';
BrowserModule,
AppRoutingModule,
PostModule,
SharedModule,
HttpClientModule
],
providers: [],
......
......@@ -3,4 +3,6 @@
<p>Title: {{displayPost.getTitle}}</p>
<p>Description: {{displayPost.getDescription}}</p>
<p>Timestamp: {{displayPost.getTimestamp}}</p>
<p>Owner: {{displayPost.getOwner}}</p>
\ No newline at end of file
<p>Owner: {{displayPost.getOwner}}</p>
<app-text-input></app-text-input>
\ No newline at end of file
......@@ -36,6 +36,6 @@ describe('PostFormComponent', () => {
})
it('should deserialize Post', () => {
expect(component.deserializedPost.getUser).toEqual("Admin");
expect(component.deserializedPost.getOwner).toEqual("Admin");
})
});
......@@ -21,14 +21,14 @@ export class PostFormComponent implements OnInit {
title: "TestAnnonse",
description: "Beskrivelse",
timestamp: 1612952332000,
user: "Admin",
owner: "Admin",
imageUrl: "url"
});
this.serializedPost = post.serialize();
this.deserializedPost.deserialize(post.serialize());
this.postService.getPost(0)
this.postService.getPost(1)
.then((gettedPost: Post) => {
this.displayPost = gettedPost;
}).catch((err: any) => {
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PostFormComponent } from './post-form/post-form.component';
import { SharedModule } from '../shared/shared.module';
......@@ -9,7 +10,8 @@ import { PostFormComponent } from './post-form/post-form.component';
PostFormComponent
],
imports: [
CommonModule
CommonModule,
SharedModule
]
})
export class PostModule { }
......@@ -30,7 +30,7 @@ export class PostService {
);
}
get_post(id: number) {
private get_post(id: number) {
return this.http.get(this.postUrl + id);
}
......@@ -48,7 +48,7 @@ export class PostService {
);
}
add_post(post: Post) {
private add_post(post: Post) {
return this.http.post(this.postUrl, post.serialize());
}
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TextInputComponent } from './text-input/text-input.component';
@NgModule({
declarations: [TextInputComponent],
exports: [TextInputComponent],
imports: [
CommonModule
]
})
export class SharedModule { }
<input type="text" id="textField">
\ No newline at end of file
#textField{
padding: 5px;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TextInputComponent } from './text-input.component';
describe('TextInputComponent', () => {
let component: TextInputComponent;
let fixture: ComponentFixture<TextInputComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ TextInputComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(TextInputComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-text-input',
templateUrl: './text-input.component.html',
styleUrls: ['./text-input.component.scss']
})
export class TextInputComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
......@@ -4,7 +4,7 @@
"description": "REST API with MySQL",
"main": "src/index.ts",
"scripts": {
"start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts",
"start": "nodemon --watch 'src/**/*.ts' --exec \"ts-node\" src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment