Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Angular Frontend 06: Dummy Daten in Services

02.02.2023 (πŸ‘2034)


 

Dummy daten erstellen im Service

In der Service Datei wird nun eine function getArticles() erstellt, welche einen dummy-datensatz anzeigt.

Ein Bild, das Text enthΓ€lt.

Automatisch generierte Beschreibung

 

Datei: services/articles.service.ts

Articles.service.ts

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

import { Article } from '../models/article';

 

@Injectable({

  providedIn: 'root'

})

export class ArticlesService {

 

  constructor() { }

 

  //mock-data

  public getArticles(): Article[]{

    //*create a dummy article

    let article=new Article();

      article.id=1;

      article.title="this is Article 1";

      article.text="text of this article";

      article.html="<p>text of this article</p>";

 

      //*output as return

      return [article];

 

  }

}