Ionic2 NavController popToRoot - ionic2

I am using Ionic 2 rc4.
I am trying to use the NavController to go back to the root page.
I have:
Page1 (root) -> Page2 -> Page3
I use:
this.nav.popToRoot().then(() => {
this.events.publish('popupFilter:update', data);
});
When I am on Page3, I expect it to pop to Page1 However, it does not pop to the root, but rather only one page back (Page2).
Any ideas what I am doing wrong?
Secondly, how can I see what pages are in the stack?
Thanks

you can set root page rather than pop. try to use following command
this.navCtrl.push(root);
i hope its work for you.

Related

How To set aria-pressed="true" in Selenium?

HTML:-
<ion-segment-button class="segment-button" role="button" tappable value="sign_in" aria-pressed="false">
Selenium Code:-
WebDriver driver = new ChromeDriver();
driver.get("URL");
WebElement Login =driver.findElement(ByClassName.className("segment-button"));
Login.submit();
How To set aria-pressed="true" in Selenium??
There is no direct way to set the attribute of a element in selenium. But we can use the javascript Executor to set attribute of a element as given below.
WebDriver driver = new ChromeDriver();
driver.get("URL");
WebElement Login =driver.findElement(ByClassName.className("segment-button"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("arguments[0].setAttribute('aria-pressed',true);",Login);
The short answer is don't. Don't do this unless you really know what you are doing and understand the site. Forcing values on elements using JS shortcuts all the events that the site has to handle this user flow and you could put the page in a bad state. No user is going to run JS on the page to put it in the desired state... your script shouldn't either.
The right way to do this is to figure out how this gets set from a user's perspective. What buttons do I have to push, etc. to get the desired setting? Once you figure that out, write the Selenium code to push those buttons, etc. and you will have the desired result.

react-router-redux - app doesnt re-render after dispatching a push-action

I'm trying to integrate the newest Version of react-router & react-router-redux into sample application from a react-book. But i can't get the example working with routing over react-router-redux push/replace function.
I'm not certain if its a bug or i'm using the functions wrong.
actions/index.js
...
export function dismissVote(history) {
// this changes the history locations an application re-renders
//return () => history.push('/votes');
// this changes the history locations but application doesnt re-render
return dispatch => dispatch(push('/votes'))
}
...
Version used (package.json)
"react-router-dom": "4.1.1"
"react-router-redux": "5.0.0-alpha.6"
App Repository (clone from github)
https://github.com/ap0yuv/voteapp.git
How to reproduce my issue
clone the repo.
cd ./myapp
npm run start:hot && npm start
Launch Application in Browser # localhost:3000/votes/vote_1
Click Button "Vote later"
Expected Behavior
Browser Location is changed to localhost:3000/votes/
AND
The List of all votes (localhost:3000/votes) is visible (VotePage)
Actual Behavior
Browser Location is changed to localhost:3000/votes/
AND
Page of Current Vote (vote_1) is still shown
If i pass the history object to the function to route, the proper page is displayed.
More Information about the code:
src/common/containers/SingleVotePage is the entry point for /votes/vote_1
and passes dismissVote() from src/actions to

ember serve and browser reload results in "cannot GET /foo" with custom Ember.Location

TL;DR: Added custom location type to environment.js then ember serve -> open browser to route /foo -> cannot GET /foo
Followed the instructions at https://www.emberjs.com/api/classes/Ember.Location.html#toc_custom-implementation and copied the code exactly as it appeared into a file called app/locations/history-url-logging.js, added a line to config/environment.js that said:
ENV.locationType = 'history-url-logging';
For reference, the code given in the docs is simply:
import Ember from 'ember';
export default Ember.HistoryLocation.extend({
implementation: 'history-url-logging',
pushState: function (path) {
console.log(path);
this._super.apply(this, arguments);
}
});
I decided to restart the server, did the usual CTRL+C to ember s then did ember s again. I went back to my browser sitting on one of the routes, hit F5, and received the cryptic error:
Cannot GET /contacts
So, after MUCH Googling and trial and error (and posting a previous question here which I just edited with this text you're reading), I discovered that to FIX that error, all I had to do remove the config line ENV.locationType = 'history-url-logging';, restart the server (ember s), and suddenly the app worked fine!
What's even more odd is that if I start the app without that line in environment.js, then once the app is running (and the browser window reloads just fine, etc), then I re-add the line that says ENV.locationType = 'history-url-logging'; (which triggers a live reload), and the app still works fine! (E.g. hitting F5 to reload the page doesn't vie me the "Cannot GET /contacts" (or whatever the route is) error.) And, of course, the console gives me the "console.log" output as expected from the code above.
So, long and short of it, using a custom location totally seems to screw up ember serve - which is really sad and frustrating! Any ideas how to fix this?
Ember built-in server looks at the environment.js locationType property to figure out if it must serve routes after the rootURL path. By default, if the locationType is history it will do it. It uses string matching.
In your case you wrote your own location, inheriting from HistoryLocation therefor the locationType property in the environement.js is now history-url-logging. The built-in server doesn't recognize it as a history based form of location just by the name. It will default to hash location. It doesn't analyze your code.
For this scenario, we have to help the built-in server to understand that the locationType is equivalent to a history location.
You need to add historySupportMiddleware: true in your environment.js file right after the locationType property.

Ionic2 InAppBrowser

Hi I want to put a button in my page when clicked it will launch the website of the given item. However I got a problem and I don't know how to fix it. I just followed a recent tutorial online but unfortunately it didn't worked for me.
1.) This is the error appearing when I click on the button, circled in the image.
2.) Declaration of the constructor in the js file
3.) html button
4.) App version
Add
import {InAppBrowser} from 'ionic-native';
Also I did not see this in your .js file
launch(url) {
this.platform.ready().then(() => {
open(url, "_blank", "location=no");
});
}
This is required.
Add
cordova plugin add cordova-inappbrowser
In your ts file just add this line under your imports and above your #component
declare var cordova ;
Once the platform is ready just add the below lines.
cordova.InAppBrowser.open(url, '_blank', 'location=yes')
Here is the example explained as how to open a browser in ionic-2.
https://www.thepolyglotdeveloper.com/2016/01/launch-websites-with-ionic-2-using-the-inappbrowser/

Angularjs refresh ng:view

While using Angularjs v0.9 and php to implement my membership system
In this following function, I will call an api to edit the data of the member, on success, the php function will return
{"success":"true"}
and the controller will return to a page that can view the member of the data.
if(response.success==="true") {
window.location="#/register_members";
$('.alert-error').hide();
$('.alert-success').html("Member is updated.");
$('.alert-success').fadeIn();
}
However, at #/register_members, the data still remains as the unchanged data. Is there anyway I can refresh the page partially in angularjs? I am using ng:view and $route.
I have tried using
window.location.reload(true);
but the success message will not be rendered as the whole page is renewed.
Does anyone have any idea?
Found an interesting answer here to refresh a div in the page using Jquery
my page is "#/register_members"
the div i want to update is "#registerlist" which is inside a div called "#browse-box".
so now my controller will be
window.location="#/register_members";
$("#browse-box").load("/#/register_members #registerlist")
$('.alert-error').hide();
$('.alert-success').html("Member is updated.");
$('.alert-success').fadeIn();
works like a charm. :)