1
This is the error you are making when calling the api. think this is something in exiting the api or receiving it in my other project?
ERROR Error: Cannot find a supporting differ Object '[Object Object]' of type 'Object'. Ngfor only Supports Binding to Iterables such as Arrays.
Code of the web api:
public IList<RepresentanteConsulta> ConsultaSelect(int? cod, string type)
{
try
{
using (ISession session = SessionFactory.OpenSession())
{
ClienteRepository cli = new ClienteRepository();
IDictionary<String, object> dbParameters = new Dictionary<String, object>();
StringBuilder sb = new StringBuilder();
sb.AppendLine("SELECT REPCN_REPRESENTANTE \"Codigo\", REPNM_REPRESENTANTE \"Nome\"");
sb.AppendLine("FROM T_REPRESENTANTE REP JOIN T_REPRESENTANTE_X_CLIENTE REPCLI ON (REPCLI.ISN_REPRESENTANTE = REP.ISN_REPRESENTANTE) ");
sb.AppendFormat("WHERE REPCLI.ISN_CLIENTE = {0} ", cod);
return CreateSQLQuery<RepresentanteConsulta>(sb.ToString(), dbParameters);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
Call still in the web api controller:
public JsonResult SelectPesquisa(int cod, string type)
{
switch (type)
{
case "rep":
return Json(new { teste = representanteRepository.ConsultaSelect(cod, type) }, JsonRequestBehavior.AllowGet);
}
return Json(new { result = "Não implementado" }, JsonRequestBehavior.AllowGet);
}
Call in the other angular project:
switch (type) {
case "rep":
params = params.set('cod', formGroup.controls['codigoCliente'].value);
this.retornaNomeApi(NEGOCIUS_API + '/Pesquisa/SelectPesquisa', params).subscribe(res => {this.teste = res;console.log(this.teste)})
return this.teste;
}
Possibly you should not have an array.
– Lucas Brogni
I managed to solve and really was on the api part, had an object inside another object, thanks anyway for the comment!!
– Bruno Miqueas