Start a new topic

Can't get the navigation hooks to work on the home.component

I can't get the "this.page.on("navigatedTo", () => {})" and "this.page.on("navigatedFrom", () => {})" to work on my home.component. It works on other components but not for home.

Is there anything different from home.components and the other view components that I create by myself?


//Thomas 


Hello Thomas,


The Kinvey Studio applications are using the NativeScript Angular flavor and depend on the Angular Router for in-app navigation. Using the core (vanilla) NativeScript navigation (navigatedTo, navigatedFrom and so on) is possible, but mixing the two will introduce a lot of complexity and might cause issues with the navigation history of the app (for example, some of the built-in functionality like the software and hardware back buttons may be broken).


Having said that, I recommend that you check the NativeScript Angular Navigation docs for more details about the capabilities of the Angular Router. Also, if you can share your particular scenario, I might be able to provide more detailed information on the subject.


I hope this is of any help.


Regards,

Garo

Hi Garo,


My problem is what I think very basic. Let sat you have the main view where you show data fetched from Kinvey. From that view, you have an edit button wish takes you to an edit view where you will be able to update the back to Kinvey. When navigating back to the main view you would like to have that view updated to show the newly updated data from Kinvey.


What is your recommendation to implement this behavior?


//Thomas

Hello Thomas,


If I understand you correctly, you can achieve this scenario directly through Kinvey Studio, without the need to write custom code.


You can add a new ListView of any type (for example, Single Line or Two Lines) and associated it with a backend collection through the DATA CONNECTIONS section in the INSPECTOR. Now, creating a view to add new elements to the backend can be generated automatically by clicking on the cogwheel icon next to the respective view in the VIEWS pane and selecting Create Form (works only for ListView views). You can then select the ListView view, scroll to the bottom of the INSPECTOR, enable the Add New Item Button checkbox and select the newly generated view from the drop-down below the checkbox. With this change in place, you can now add new items to your collection and have them visualize in the ListView.


Having said that, you can use the same approach to create a view that shows detailed information about an item when it is selected - however, instead of attaching it to the Add New Item "navigation", you should select the view from the drop-down under CONFIGURATION & FEATURES (Select a view to navigate to when an item in a list is tapped). While this introduces a straightforward way to update an item, it's not a perfect solution, as it would directly open an editable form when you select an item from the ListView. With this in mind, perhaps the better approach would be to create a custom view and structure it based on your preferences - for example, with images and labels, and add an edit button to it, that would open the editable form.


Let me know if you experience difficulties with setting that up, so I can a provide more detailed explanation.


Regards,

Garo

Login or Signup to post a comment