gethuman / nativescript-sidedrawer

SideDrawer menu plugin for Nativescript - iOS/Android
Other
41 stars 10 forks source link

how to navigate #4

Open oncul opened 7 years ago

oncul commented 7 years ago

hello i cant navigate page when i add sidedrawer.

exports.onLoaded = function(args){
    page = args.object;
    page.bindingContext = viewModel;

    TnsSideDrawer.build({
        templates: [
            {
                title: 'Home',
            },

            ],
        title: 'This App Name',
        listener: function(index){
                      frameModule.topmost().navigate('test');
        }
    });

};
orlowdev commented 7 years ago

This is what I did using Angular and TypeScript.

// All the code you need to set the drawer up
...
listener: (index) => {
  this.handleDrawerItemTap(index); // Call the function or place the switch right here
},
...
// All the rest

// Consider index to follow appropriate route. The order is 0-based and matches the order
// of your drawer items initialized in 'templates'. Bear in mind that you need to inject the 
// Router into your component.
private handleDrawerItemTap(index : number) : void {
  switch (index) {
    case 0:
      this.router.navigate(["/foo"]);
      break;
    ... // Other cases
  }
}
ButterMeWaffle commented 7 years ago

has anyone found an issue with data binding when using the above method?

When the above method is used my page is not populated with data.

However if I can to the exact same page from outside of the sidebar, the data appears as it should.

orlowdev commented 7 years ago

It could potentially take place, but it is not the problem with sidedrawer, this is due to the router behaviour. Code is needed to replicate the issue.

ButterMeWaffle commented 7 years ago

@apologetics using a custom made side drawer and the exact same functions my issue was resolved. Somehow when the function is called, via the index function of the plugin, ngmodels do not like to work even with data present. This doesnt make much sense to me but I haven't had time to investigate it

ecopenhex commented 7 years ago

@SamuelGRwebfab could you attach the code? Please. I have the same issue, when click the model doesn't work. Thanks.

Saguntamrakar commented 7 years ago

@SamuelGRwebfab I am having the same problem. Could you tell me how you did it?

Saguntamrakar commented 7 years ago

I solved it by using this.routerextension.navigate(['/LeaveInfo'], { clearHistory: true, animated: false }) instead of this.router.navigate(["/foo"]);

ButterMeWaffle commented 7 years ago

@ecolasurdo i switch to a custom radsidedrawer instead of using the plugin. however @Saguntamrakar fix may work but would cause history issues is you like to use the goBack function

sychus commented 6 years ago

Hi boys! I have the same problem as @SamuelReeder !! I think that is a sidedrawer problem. If I use a button instead sidedrawer populates perfectly! Please Help!