示例中,根据ng-if指令显示不同任务状态,以及判断任务是否可以操作
任务列表
任务编号 任务名称 任务状态 操作 { { item.Id }}
{ { item.TaskName }}
准备开工
进行中
已经完成
Controller
public ActionResult GetNgifData(){ Listlist = new List (); list.Add(new TaskModel() { Id = 1, TaskName = "任务1", OwnStatus = Status.todo }); list.Add(new TaskModel() { Id = 2, TaskName = "任务2", OwnStatus = Status.done }); list.Add(new TaskModel() { Id = 3, TaskName = "任务3", OwnStatus = Status.doing }); list.Add(new TaskModel() { Id = 4, TaskName = "任务4", OwnStatus = Status.doing }); list.Add(new TaskModel() { Id = 5, TaskName = "任务5", OwnStatus = Status.todo }); return Json(list);}
Model
public enum Status{ todo=0, doing=1, done=2}public class TaskModel{ public int Id { get; set; } public Status OwnStatus { get; set; } public string TaskName { get; set; }}