asp.net mvc 4 - RouteLink with Knockoutjs template item properties -


i have template rendering template via foreach: viewmodel.foos. on template this: @html.routelink("view", "foo", new { id = fooid, text = fooname }). being fooid , fooname properties of view model.

i've added template:

<a data-bind="attr: { href: url }">view</a> 

and foo object:

public class foo : foobase {     public long fooid { get; set; }     public string fooname { get; set; }      public string url {         {             return string.format("/foo/{0}/{1}", fooid, fooname         }     } } 

the cons:

  • painfully scalable.

the pros:

  • simplicity.

Comments