Created
December 2, 2013 17:23
-
-
Save KyleGobel/7753052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var self = this; | |
var uglyVm = { | |
object1 : ko.observable("hello there"), | |
object2 : ko.observable(new (function () { | |
var self = this; | |
self.subObject1 = ko.observable("goodbye now"); | |
})(self)) | |
}; | |
//should also work the same as this (relatively) | |
var simpleVm = { | |
object1 : ko.observable("hello there"), | |
object2 : { | |
subObject1 : ko.observable("goodbye now") | |
} | |
}; | |
//another way, to seperate them out even farther | |
//create the subVm seperate, probably as a function returning an object | |
//with a constructor to just pass your values in | |
//like: | |
// new subVm(item1, item2, addressId, "some other property"); | |
var subVm = { | |
subObject1 : ko.observable("goodbye now") | |
}; | |
var simplarVm = { | |
object1: ko.observable("hello there"), | |
object2: new subVm(/*with arguments of what you needed to fill at runtime */)) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment