NativeScript for Mobile App Development Navigation and Routing 1 — Questions and Answers
Question 1: Which NativeScript module handles page-to-page navigation in a plain JS/TS app?
- Frame (Correct answer)
- Router
- Navigator
- NavController
Correct answer: Frame
The Frame module manages the navigation stack, and you call Frame.topmost().navigate() to move between pages.
Question 2: Which method navigates to a new page in plain NativeScript?
- frame.navigate({ moduleName: 'page' }) (Correct answer)
- frame.push('page')
- frame.go('/page')
- frame.open('page')
Correct answer: frame.navigate({ moduleName: 'page' })
frame.navigate() accepts a NavigationEntry object with moduleName pointing to the page file to navigate to.
Question 3: How do you pass data to a new page during navigation in NativeScript?
- Using the context property in NavigationEntry (Correct answer)
- Using URL query parameters
- Using global variables
- Using localStorage
Correct answer: Using the context property in NavigationEntry
The `context` property of NavigationEntry carries any object to the destination page, accessible via the navigationContext on the target page.
Question 4: Which property of NavigationEntry clears the navigation back stack?
- clearHistory: true (Correct answer)
- resetStack: true
- clearBack: true
- replaceAll: true
Correct answer: clearHistory: true
Setting `clearHistory: true` in the NavigationEntry removes all previous pages from the back stack, preventing the user from going back.
Question 5: In NativeScript Angular, what module provides routing functionality?
- NativeScriptRouterModule (Correct answer)
- RouterModule
- NsRouterModule
- AppRoutingModule
Correct answer: NativeScriptRouterModule
NativeScriptRouterModule from @nativescript/angular replaces Angular's standard RouterModule with native mobile navigation support.
Question 6: How is page back navigation triggered programmatically in NativeScript?
- frame.goBack() (Correct answer)
- frame.back()
- frame.pop()
- frame.navigate(-1)
Correct answer: frame.goBack()
Calling `frame.goBack()` programmatically navigates to the previous page in the navigation stack.
Which NativeScript module handles page-to-page navigation in a plain JS/TS app?