How to check if a page component is created by a navController or a modalController - modal-dialog

I have a lazy loaded IonicPage Component.
Which can be called in two ways:
navController.push('pageName');
modalController.create('pageName');
Both work well.
Is there a way I can check from within the IonicPage Component to see if it has been created by the navController or the modalController?
Plan B. I can pass a navParam with both e.g. isModal=true to fix this, but I am curious if there is an easier way to check how a page is created.
Context: The page is a component with a list of say users. If the component is loaded as a page (see 1. above) then when we click on an user you can edit its details. But when the component is presented as a modal and we click on it, the details of the clicked user is passed back to the previous page for processing.

Related

How can I make use of Event Delegation in a parent Svelte Component

In this example, if I click the Tutorial NavItem I get to the Tutorial
section. Here I forward an custom click event on every Nav Item, where I set the segment which has been clicked. In the app.svelte I pull in the NavItem component and set the segment to current, which tells the Nav Component (through Props), which segment is current and needs to be active.
My question is how Can i Make use of event Delegation, so the Nav Component listen for the click Event, so it doesn't feel so repetitiv
The minimal Example goes like that, I want the parent to handle the event?:
https://svelte.dev/repl/691e82ee168549c782b61c355e78cf9b?version=3.12.1
Here is a complex Ex. the Repl:
https://svelte.dev/repl/691e82ee168549c782b61c355e78cf9b?version=3.12.1
I see you already use the getContext and setContext functionality. Instead of firing the event you can simply update that context:
in NavItem.svelte
function setSegment(){
current.set(segment);
}

Initializing component inside a home page in Ionic4

I have a Home Page, inside that I have created one component RecentlyViewedProductComponent.
My problem is:
when I navigate to /home by using
this.router.navigate(['/home']);
the ngOnInit() inside RecentlyViewedProductComponent is not working. When I close the app and open it again, that only it is working .
How to solve this problem?
It sounds like you are not using the right lifecycle event.
Have you looked at the documentation here:
https://ionicframework.com/docs/angular/lifecycle
It says that ngOnInit() is:
Fired once during component initialization. This event can be used to initialize local members and make calls into services that only need to be done once.
If you want it to be called every time you navigate to the home page then you want to replace this with something like ionViewWillEnter():
Fired when the component routing to is about to animate into view.
There is actually some guidance at the end of the docs page that you might find interesting which explains when to use each life cycle method.

SapUI5 how can I navigate to a page after validating data within onInit?

In my app, I have a complex page that doesn't want to be run unless search criteria have been input on a previous page. The validation is easy, but if I do a getRouter.navTo within the onInit function, my target page runs it's onInit, but the view that get's rendered is that of the page that I redireced from.
I have found that I can get this to work by using window.setTimeOut to defer the navTo until after the onInit, but there surely is a better way that this isn't there?
It would be ideal if the first page didn't even render, with the second page being the only one visible.
If you don't want the first page to be rendered, you can do your validation in the onBeforeRendering method. That way you can execute your validation before your page is rendered.

How to hook GWT navigation from a userscript?

I'm writing a userscript for a GWT-based site.
My script uses URL of the page as input. It should be update each page of the site with additional information.
Unfortunately, as view changes in GWT are implemented via rerendering (only location anchor in browser address-bar is being changed), clicks on internal links are not recognized as page loads and Greasemonkey does not invoke my script, leaving new views unmodified.
Is there a way to hook in GWT-based navigation from an userscript? I need a way to modify each "change" Gerrit navigates to.
Complete workflow should look like:
User scans through the list of issues
User clicks on a link . (Address bar will assume a location of a change being clicked, for example https://git.eclipse.org/r/#/c/38781/)
Page is modified by userscript to contain information about new view (in our case /c/38781/)
Greasemonkey is only invoked at the first step of this workflow, and I don't know ho to detect second one to be able to trigger the third.
I've tried to observe DOM changes on the page, but my listeners are never called probably due to the fact GWT renders some parts via innerHTML property, without explicit child manipulation.

Durandal: Manually remove view from DOM

i am creating a single page application using HotTowel SPA, which uses Durandal 2.0
I have two views, named Dashboard and Settings.
When i load the website, the Dashboard view gets loaded. When i click on Settings, the Dashboard view gets deactivated, and when i click on Dashboard, it gets activated again.
I have a method on my Settings View. When this method is called, i want the Dashboard view to be removed from the DOM. so that when I click on Dashboard again, it has to reload the view (just like it does when you reload the webpage), in stead of just activating it.
So is there a way to detach a view manually?
You can cacheViews to false on the composition binding. See about 3/4 down the Using Composition
page.
In the shell.html file (I presume it's the same in HotTowel), there will be a line like:
<div class="container-fluid page-host" data-bind="router: { transition:'entrance', cacheViews:false }"></div>