2
What are variables for @model
and Model
in a view?
In my view I use it at the beginning of the code:
@using Html5DataList.Models
@model List<Estabelecimento>
And to access the data, I use it like this:
@foreach (var item in Model)
{
<option value="@item.unidadeId">@item.cnes - @item.nomeFanta</option>
}
Man controller is like this:
public ActionResult BPAC()
{
List<Estabelecimento> listaEstabelecimento = new Estabelecimento().listaEstabelecimento();
return View(listaEstabelecimento);
}
It works properly, but I use it just because I’ve seen it like this, I still don’t know what it means.
And, if I want to send more than one information? Ex:
public ActionResult BPAC()
{
string teste = "teste";
List<Estabelecimento> listaEstabelecimento = new Estabelecimento().listaEstabelecimento();
return View(listaEstabelecimento, teste);
}
In this case, how do I receive the variables listaEstabelecimento
and teste
?