What are the @model
and Model
variables in a view ?
In my view I use this 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>
}
My controller looks like this:
public ActionResult BPAC()
{
List<Estabelecimento> listaEstabelecimento = new Estabelecimento().listaEstabelecimento();
return View(listaEstabelecimento);
}
It works correctly, but I use it only because I've seen it like this, actually I still do not 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 get the variables listaEstabelecimento
and teste
?