Created
September 3, 2015 21:29
-
-
Save jbnv/ce18a6600c6f7547cfd9 to your computer and use it in GitHub Desktop.
An example of view composition in Durandal. From Durandal's HTML Samples download.
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
<div> | |
<h2>Child View One</h2> | |
<span data-bind="text: $root.propertyOne"></span> | |
</div> |
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
<div> | |
<h2>Child View Two</h2> | |
<span data-bind="text: propertyTwo"></span> | |
<div data-part="content">Some default content goes here.</div> | |
</div> |
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
<section> | |
<h1>The Views Below Are Composed In Different Ways</h1> | |
<!--ko compose: 'childView1.html'--><!--/ko--> | |
<!--ko compose: 'childView2.html'--><!--/ko--> | |
<!--ko compose: { model:'viewComposition/inlineModule', mode:'inline'}--> | |
<h3 data-bind="text: someProperty"></h3> | |
<!--/ko--> | |
<!--ko compose: { view:'childView2.html', mode:'templated' }--> | |
<div data-part="content">This is a view part override of the default content....</div> | |
<!--/ko--> | |
</section> |
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
define(function() { | |
return { | |
propertyOne: 'This is a databound property from the root context.', | |
propertyTwo: 'This property demonstrates that binding contexts flow through composed views.' | |
}; | |
}); |
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
define(function(){ | |
return { | |
someProperty:'This is being bound against an inline view.' | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment