开发者

How do I use knockoutjs with ScriptSharp?

开发者 https://www.devze.com 2023-03-23 09:29 出处:网络
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 contain

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开发者_StackOverflow中文版 few knockout Observables and how to use the basic function like GetValue and SetValue.

Thanks for your attention.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消