Skip to content

Instantly share code, notes, and snippets.

@nhamilakis
Last active October 16, 2019 08:59
Show Gist options
  • Save nhamilakis/978289c0b16008029d7555e0305f11ba to your computer and use it in GitHub Desktop.
Save nhamilakis/978289c0b16008029d7555e0305f11ba to your computer and use it in GitHub Desktop.
Get Stuff in Angular
class Corpus {
name: string;
}
@TrucAngularAUZEF
class MyCorporaComponent extends OnInit {
listCorpora : Array<Corpus> = [];
constructor(private api: MyAPIServiceDeLEspace){}
ngOninit(){
// se truc se lance a chaque l'initiation du component
this.api.getCorpus(1).subscribe(
(data) => this.listCorpora = data,
(err) => console.log('fuck there was error : ${err}'),
);
}
}
@injectStuff
class MyAPIServiceDeLEspace {
constructor(http: NGHTT){}
getCorpus(id: string){
return this.http.get('http://api/corpus/' + id )
}
}
<div *ngFor="corpora of listCorpora">
<span> {{ corpora.name }} </span>
</div>
@nhamilakis
Copy link
Author

file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment