i pull data from my mysql database with angular http and have a last field that contains data which is separated by a ";" but its only a string.
Now i want to have a single html element for each of this values. But on top of that i want that for each record in my database.
I thought of something like this: (Template) The Pipe turns the String into an array
<li *ngFor="let form of data">
{{form.idform_data}} - {{form.form_name}} -
{{form.field_name}} - {{form.field_type}} -
{{form.field_desc}} -
<ng-template *ngFor = "let item of {{form.field_data | splitAndGet : ";"}}">
{{item}}
</ng-template>
</li>
But that wont work because the error is Unexpected closing tag "li"
If you need further code just tell me.
Would really appreciate some help right here!
Edit1: closed ng-template tag
Error now is Key[0] is undefined but i know that the array contains values
Edit2: Code Data Gathering
import { Component } from '@angular/core';
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
private data;
constructor(private http:Http){
}
ngOnInit(){
console.log("ngOnInit");
this.getData();
}
getData(){
console.log("fetching Data");
this.http.get('http://192.168.178.42/getFormDbData.php') //Pfad zur php datei
.subscribe(response =>{ this.data = response.json()
console.log(JSON.stringify(response.json()))});
}
}
Pipe:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: "splitAndGet" })
export class SplitAndGetPipe implements PipeTransform {
transform(input: string, separator: string, index:number): any {
var splitarr = input.split(separator);
return splitarr;
}
}
Edit : thanks for helping. Also thanks for Downvoting that helps people like me which begin to learn something.