0

I'm learning developing cross-platform mobile-client app with nativescript. It turns out the UI component is extremely limited in nativescript and everytime I try to learn the official document, it leads me to angular2 docs. I know, nativescript uses angular2, but the examples in angular doesn't work on mobile client?

For example: template: <button (click)="onClickMe()">Click me!</button> this kind of code can only work for web-app, it doesn't support the nativescript mobile client development, it can complie but there is nothing display, the formatting is somehow different:

<Button (tap)="onClickMe()" text="!" ></Button>

The above code is the code I'm looking for. But I can't find documents that tells me how to transfer between them. All the documents I found is about the first code.

I'm really struggling with this, I can't even find "radioButton" for mobile client:(

Just wanna know why the first code can't work on my ios simulator for the mobile app but the second one can? Aren't they all typescipt?

I'm new to this so maybe my question is dumb~~

Thank you for your patience!

2
  • What I know from shallow styding of NativeScript is that it uses angular2, but don't use dom (that we normally use in web dev). And ability to change renderer behind the scene, could be strong part of angular2 modularity/interoperability. In nativescript they created something own, that hooks your view to native components. But I agree the documentation was not so good a year ago when I was looking at it. Commented Feb 28, 2017 at 21:59
  • It's also more accurate to state NativeScript supports Angular and not uses it. Because the core of nativescript is just javascript, the angular framework is an optional add on. Commented Feb 28, 2017 at 22:23

1 Answer 1

4

When using NativeScript with Angular you're not supposed to share the view layer with a browser version of the app. In fact that's (almost the) only thing you'll need to implement twice.

Please look at the docs to see how you create the UI components: https://docs.nativescript.org/angular/ui/components.html

Regarding radio buttons.. I have yet to see a radio button in a native app. Usually apps use switches and list pickers as they're easier to operate than radio buttons.

If you want to share lots of code between your mobile app and browser version (and possibly even a desktop version) then I'd highly recommend this seed as a starting point for your app: https://github.com/NathanWalker/angular-seed-advanced

If you just want to learn more about how NativeScript uses Angular, follow this tutorial: http://docs.nativescript.org/angular/tutorial/ng-chapter-0

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.