nativescript - Pass arguments to custom component -
i created component , nice use ;) don't know how pass arguments;
use:
<page xmlns="http://www.nativescript.org/tns.xsd" xmlns:mastermenu="includes/customcomponents/mastermenu"> <mastermenu:mastermenu selected="1"/> </page> how can catch selected in component? have mastermenu.xml , mastermanu.css files.
[ edit ]
let have component named question (pseudo code):
xml
< stacklayout loaded="loaded">
< label text="question: loremipsum" /> < label text="answer 1" id="answer1" /> < label text="answer 2" id="answer2"/> < label text="answer 3" id="answer3"/>< /stacklayout>
js
exports.loaded = function(args) {
var answerno = args.answerno, page = args.object; page.getelementbyid(page, "answer"+answerno).addclass('correct')}
used :
< page xmlns="http://www.nativescript.org/tns.xsd" xmlns:question="includes/customcomponents/question">
< question:question answerno="2" />
< question:question answerno="1" />
< question:question answerno="3" />< /page>
in javascript access this:
var menu = page.getviewbyid("idofmenucomponent"); menu.selected; that assuming it's available accessed. depend on how have component created. if it's not available need add property component. have @ <button> module see how can done.
Comments
Post a Comment