2016-09-21 2 views
1

전 nativscript에 익숙하지 않습니다. nativescript-checkbox를 사용하고 있습니다. checkbox.i에서 가치를 얻고 싶습니다. git hub에서 보았지만 속성을 얻는 솔루션을 찾지 못했습니다. https://libraries.io/npm/nativescript-checkboxNativescript에서 확인란의 가치를 얻으려면 어떻게해야합니까?

의견이 있으십니까?

+0

당신은 지금까지 시도? – salih0vicX

+0

당신이 포함하는 링크는 체크 박스의 속성을 얻는 방법을 모두 말하며 매우 간단합니다. 너의 문제는 무엇인가? 코드를 공유 할 수 있습니까? –

답변

1

다음은 nativescript-checkbox 플러그인에서 확인란을 처리하는 방법에 대한 매우 기본적인 예입니다.

당신이 코드를 공유하시기 바랍니다 수 타이프 라이터 활성화 프로젝트

에서 page.xml

<Page xmlns="http://schemas.nativescript.org/tns.xsd" 
     xmlns:CheckBox="nativescript-checkbox" 
     loaded="pageLoaded"> 
    <StackLayout> 
    <CheckBox:CheckBox text="CheckBox Label" id="myCheckbox" checked="false" /> 
    <Button text="on toggleCheck" tap="toggleCheck" /> 
    <Button text="on getCheckProp" tap="getCheckProp" /> 
    </StackLayout> 
</Page> 

page.ts

import { EventData } from 'data/observable'; 
    import { Page } from 'ui/page'; 
    import { CheckBox } from 'nativescript-checkbox'; 
    import { topmost } from 'ui/frame'; 

    let page; 

    export function pageLoaded(args: EventData) { 
     page = <Page>args.object; 
    } 

    export function toggleCheck() { 
     let checkBox = <CheckBox>page.getViewById('myCheckbox'); 
     checkBox.toggle(); 
    } 

    export function getCheckProp() { 
     let checkBox = <CheckBox>page.getViewById('myCheckbox'); 
     console.log('checked prop value = ' + checkBox.checked); // will return true of false 
    } 
관련 문제