Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use knockoutjs with ScriptSharp?

As I have just learnt the Script# that I don't know how to use knockoutjs with ScriptSharp. I tried to read through the KnockoutAPI but I am still confused how to write even just a view Model containing just few knockout Observables and how to use the basic function like GetValue and SetValue.

Thanks for your attention.

like image 827
nelsonwrong Avatar asked Jul 26 '11 04:07

nelsonwrong


1 Answers

You can do something like this:

public class MyViewModel {

    public Observable<string> firstName = Knockout.Observable<string>("Bob");
}

public static class App {

    static App() {
        MyViewModel vm = new MyViewModel();
        Knockout.ApplyBindings(vm);
    }
}

Hope that gets you started.

like image 65
Nikhil Kothari Avatar answered Oct 29 '22 12:10

Nikhil Kothari