Click here to Skip to main content
15,892,298 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Controller, Include in Project Pin
Nathan Minier7-Aug-18 3:43
professionalNathan Minier7-Aug-18 3:43 
GeneralRe: Controller, Include in Project Pin
Wiep Corbier7-Aug-18 3:45
Wiep Corbier7-Aug-18 3:45 
PraiseRe: Controller, Include in Project Pin
Richard Deeming7-Aug-18 4:03
mveRichard Deeming7-Aug-18 4:03 
QuestionMessage Removed Pin
5-Aug-18 6:02
Member 139384675-Aug-18 6:02 
QuestionNewbie needs help with css and php Pin
kylo9991-Aug-18 3:20
kylo9991-Aug-18 3:20 
QuestionHow to make svg Icon so that user can download it? Pin
Aftab Anxari26-Jul-18 9:34
Aftab Anxari26-Jul-18 9:34 
AnswerRe: How to make svg Icon so that user can download it? Pin
OriginalGriff26-Jul-18 9:39
mveOriginalGriff26-Jul-18 9:39 
Questioncompile error in angular app Pin
deepak_201223-Jul-18 8:15
deepak_201223-Jul-18 8:15 
Hello,
I am trying to run an angular app which was working 6 months ago. While compiling i am getting following error. It was working with exact code but not sure whats causing this. I am new to angular and not sure about where i am going wrong. please advise. thank you in advance. following is error and then app files

Date: 2018-07-23T18:06:06.906Z
Hash: 4f65682650985a01a753
Time: 10797ms
chunk {main} main.js, main.js.map (main) 1.91 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 674 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in src/app/app.service.ts(19,6): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/app.service.ts(28,17): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/app.service.ts(35,6): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/app.service.ts(41,17): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/app.service.ts(47,10): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.




app.component.spec.ts


import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  }));
  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));
  it(`should have as title 'app'`, async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app.title).toEqual('app');
  }));
  it('should render title in a h1 tag', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    fixture.detectChanges();
    const compiled = fixture.debugElement.nativeElement;
    expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
  }));
});


app.component.ts


import {Component} from '@angular/core';

@Component({
  selector:'app-root',
  templateUrl:'./app.component.html',
  styleUrls:['./app.component.css']
})

export class AppComponent{}





app.service.ts
<big></big></big>


import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';

//import 'rxjs/Rx';
import { map } from "rxjs/operators";


@Injectable()
export class AppService {
    //URL for CRUD operations
    articleUrl = "http://localhost:3000/data";
    //Create constructor to get Http instance
    constructor(private http:HttpClient) { 
    }
    //Fetch all articles
    getAllArticles(): Observable<any[]> {
        return this.http.get(this.articleUrl)
	   .map(this.extractData)
	   .catch(this.handleError);

    }
	
    //Create article
    createArticle(article: any):Observable<number> {
	let cpHeaders = new Headers({ 'Content-Type': 'application/json' });
        return this.http.post(this.articleUrl, article)
               .map(this.extractData)
               .catch(this.handleError);
    }
    //Fetch article by id
    getArticleById(articleId: string): Observable<any> {
	console.log(this.articleUrl +"/"+ articleId);
	return this.http.get(this.articleUrl +"/"+ articleId)
	   .map(this.extractData)
	   .catch(this.handleError);
    }	
    //Update article
    updateArticle(article: any):Observable<number> {
        return this.http.put(this.articleUrl +"/"+ article.id, article)
               .map(this.extractData)
               .catch(this.handleError);
    }
    //Delete article	
    deleteArticleById(articleId: string): Observable<number> {
	return this.http.delete(this.articleUrl +"/"+ articleId)
	       .map(this.extractData)
               .catch(this.handleError);
    }	
    private extractData(res: Response) {
	let body = res;
        return body;
    }
    private handleError (error: Response | any) {
	console.error(error.message || error);
	return Observable.throw(error.status);
    }
} 



app.component.spec.ts
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  }));
  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));
  it(`should have as title 'app'`, async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app.title).toEqual('app');
  }));
  it('should render title in a h1 tag', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    fixture.detectChanges();
    const compiled = fixture.debugElement.nativeElement;
    expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
  }));
});

QuestionINTRODUCTION Pin
Suren Kiddo17-Jul-18 2:28
Suren Kiddo17-Jul-18 2:28 
AnswerRe: INTRODUCTION Pin
Richard Deeming17-Jul-18 3:09
mveRichard Deeming17-Jul-18 3:09 
AnswerRe: INTRODUCTION Pin
Dominur7-Aug-18 0:48
Dominur7-Aug-18 0:48 
QuestionMessage Closed Pin
10-Jul-18 5:48
Andre Hoss10-Jul-18 5:48 
AnswerRe: HTML Code Has Been Changed to Compressed Mode Pin
Nathan Minier10-Jul-18 6:48
professionalNathan Minier10-Jul-18 6:48 
GeneralRe: HTML Code Has Been Changed to Compressed Mode Pin
Richard Deeming10-Jul-18 7:07
mveRichard Deeming10-Jul-18 7:07 
GeneralRe: HTML Code Has Been Changed to Compressed Mode Pin
Nathan Minier10-Jul-18 7:17
professionalNathan Minier10-Jul-18 7:17 
QuestionLimit lines in bootstrap card-text component Pin
Urgen Dorjee6-Jul-18 1:04
Urgen Dorjee6-Jul-18 1:04 
Questionobject vs img Pin
V.4-Jul-18 20:37
professionalV.4-Jul-18 20:37 
AnswerRe: object vs img Pin
Richard Deeming5-Jul-18 1:50
mveRichard Deeming5-Jul-18 1:50 
GeneralRe: object vs img Pin
V.5-Jul-18 18:50
professionalV.5-Jul-18 18:50 
Questionstudent information Pin
Raja Jee2-Jul-18 18:31
Raja Jee2-Jul-18 18:31 
AnswerRe: student information Pin
Richard MacCutchan2-Jul-18 21:11
mveRichard MacCutchan2-Jul-18 21:11 
QuestionCode Stopped Working When Controller Method Is Invoked Using AJAX Instead Of Formaction Pin
MadDashCoder24-Jun-18 1:23
MadDashCoder24-Jun-18 1:23 
AnswerRe: Code Stopped Working When Controller Method Is Invoked Using AJAX Instead Of Formaction Pin
Richard Deeming24-Jun-18 5:04
mveRichard Deeming24-Jun-18 5:04 
QuestionMy First Web API Pin
Kevin Marois20-Jun-18 8:47
professionalKevin Marois20-Jun-18 8:47 
AnswerRe: My First Web API Pin
Richard Deeming20-Jun-18 10:53
mveRichard Deeming20-Jun-18 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.