Контроллер
public class EmployeeController : Controller
{
private IUnitOfWork _dataBase;
private IMapper<Employee, EmployeeViewModel> _employeeMapper;
public EmployeeController(IUnitOfWork dataBase, IMapper<Employee, EmployeeViewModel> employeeMapper)
{
_dataBase = dataBase;
_employeeMapper = employeeMapper;
}
public ActionResult Index()
{
return View();
}
public JsonResult Get()
{
var employees = _dataBase.Employees.GetAll();
var employeesVM = new List<EmployeeViewModel>();
foreach (var employee in employees)
{
var employeeVM = _employeeMapper.Map(employee);
employeesVM.Add(employeeVM);
}
return Json(employeesVM, JsonRequestBehavior.AllowGet);
}
}
Jsx
class Employee extends React.Component {
constructor(props) {
super(props);
this.state = { employees: [] };
}
render() {
return <div>
<p><b>{this.state.employees.Id}</b></p>
<p>Цена {this.state.employees.Name}</p>
</div>;
}
}
ReactDOM.render(
<Employee getUrl="/Employee/Get" />,
document.getElementById("employeeContent")
);
View
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<html>
<head>
<title>Employee</title>
</head>
<body>
<div id="employeeContent"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js"></script>
<script src='@Url.Content("~/Scripts/EmployeeIndex.jsx")'></script>
</body>
</html>
Почему данные на вьюшке не отображаются?