how to open external link from a ng-repeat.
I already tried different combinations but not external window opens.
when I put just one link it works but when I use expressions {{event.lermais}} to open links does not work.
this is my code:
<ion-item class="item-text-wrap item-icon-right" ng-repeat="event in events.data.results">
<img ng-src="{{ event.imagens }}">
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
I'm using Android
HTML
ng-click ="openLink(event.lermais)"
Controller
$scope.openLink= function(url){
window.open(url, "_blank", "location=yes");
}
Its a cakewalk.
you can do that bu using following eg-
<a href="{{menu.url}}" onclick="window.open(this.href,'_self');">
{{menu.title}}
</a>
this might work for you.
Related
My html file contains:
</ion-content>
<ion-content class="card-background-page">
<ion-list>
<ion-card ion-item *ngFor="let item of items" (click)="itemTapped($event,item) ">
<img src="{{item.image}}"/>
<div class="card-title">{{item.title}}</div>
<div class="card-subtitle">{{item.subTitle}}</div>
</ion-card>
</ion-list>
</ion-content>
the controller contains this code:
this.items.push(
{title:"Item 1",subTitle:"one",image:"assets/img/preview_1.png"},
{title:"Item 2",subTitle:"two",image:"assets/img/panorama_2.png"}
)
it works well when running in the browser using ionic serve, but once built for Android (with the Ionic Cloud service) the images don't get displayed on the device.
I tried:
1)./assets/img/panorama_2.png instead of assets/img/panorama_2.png
2)<img src="url({{item.image}})"/> instead of <img src="{{item.image}}"/>
but still nothing
Make sure your assets are inside src/assets/img and not inside www/assets/img
The code below works fine on a desktop browsers, where I am able to capture each keystroke. However the same code does not capture keystrokes on Android mobile browser. What could be the reason for this behavior? Thanks in advance
<div data-role="page" id="sphome" >
....
<form action="Tokens" method="GET" id="TokenSubmit" >
<input size="10" type="text" name="BToken" id="token">
....
</form>
</div>
$('#token').on('keyup',function(event){
alert(event.which);
})
Try using document on like;
$(document).on('keyup','#token', function() {
// code
});
This one should work.
I have a <ion-item> with <a> inside it. I want the apps go to specific href when the <ion-item> is clicked.
The code is working perfectly in browser emulator (ionic serve), but it cant be clicked on the android real device.
This is my <ion-item> :
<ion-item>
<a href="http://google.com">
<img src="img/ionic.png">
<p>Events</p>
</a>
</ion-item>
Note that the above href goes to external html.
The href is working if i try to go to local html :
<ion-item>
<a href="#/jobs">
<img src="img/ionic.png">
<p>Jobs List</p>
</a>
</ion-item>
I have tried change href to ng-href, i also tried specify the href inside the ion-item tag. None of them is working.
I also tried to change the order of the html :
<a href="http://google.com">
<ion-item>
<img src="img/ionic.png">
<p>Forum</p>
</ion-item>
</a>
Its still not working.
Please kindly help me, Thanks for your help
UPDATE
I also tried to use inappbrowser :
<ion-item>
<a href="#"
onclick="window.open('http://google.com', '_system', 'location=yes'); return false;">
<img src="img/ionic.png">
<p>Guide</p>
</a>
</ion-item>
But no luck on the real device
you can install in-app browser plugin in your cordova http://ngcordova.com/docs/plugins/inAppBrowser/
or if you don't want, just use $window.open('http://google.com', '_system'); in your controller
source : http://forum.ionicframework.com/t/linking-to-an-external-url-and-opening-in-browser/30953
I am testing an Android Hybrid application using Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe) which is the lastest at the moment. I also downloaded the latest ChromeDriver from here: https://groups.google.com/forum/#!topic/chromedriver-users/iBdJQHu1ipQ
The login screen in the application under test is a hybrid view (WebView). So I am switching to the proper context via calling appiumDriver.context("WEBVIEW_com.my.app.pkg")as shown below and I am also able to successfully locate and populate both the username and the password fields with the proper text data using the following code:
appiumDriver.context("WEBVIEW_com.my.app.pkg");
WebElement userNameTextField = appiumDriver.findElement(By.id("username"));
userNameTextField.click();
userNameTextField.sendKeys(new String[]{"Guest"});
WebElement passwordTextField = appiumDriver.findElement(By.id("password"));
passwordTextField.click();
passwordTextField.sendKeys(new String[]{"password"});
// The following code is not working
WebElement loginButton = appiumDriver.findElement(By.id("loginbutton"));
loginButton.click();
However, my issue is when I try to click on the login button on this screen! This is how the button is written in HTML
<div href="#" id="loginbutton" class="button">Login</div>
I tried many ways to click on the button while I am in the Web context but all so far has been in vain...This is the HTML snippet for the login screen
<div id="formbody">
<div class="line">
<input placeholder="Username" type="text" id="username" class="styled_input" value="">
</div>
<div class="line">
<input placeholder="Password" type="password" id="password" class="styled_input" value="">
</div>
<div class="line_button">
<div href="#" id="loginbutton" class="button">Login</div>
</div>
</div>
After many many attempts to click on the div/link in the Webcontext, I gave up and switched to the NATIVE context and was able to click on the button using the following code:
appiumDriver.context("NATIVE_APP");
appiumDriver.findElementByName("Login").click();
Can anyone explain to me why I am able to interact with the username and password textfields in the WebView context but have to switch to the NATIVE_APP context to be able to interact with the button?
Also note that while in the WebView context I am able to find the button ... tag by id and to call loginButton.getText(), loginButton.isEnabled(), loginButton.isDisplayed() and getTagName()
Thanks
driver.findElement(By.xpath("//*[#id=\"formbody\"]/div[3]")).click();
should work. Inspect elements on your device using chrome, this will give you exact xpath.
To inspect elements, type this command in chrome: chrome://inspect/#devices
I want to open a link say www.google.com in Phonegap Android... I've tried lot of things but I'm not able to open any link.
<access origin="http://google.com" /> is already added to config.xml.
navigator.app.loadUrl('http://google.com'); is giving an error.
$('#pageID').load('http://google.com',function(){
$('#pageID').trigger('create');
});
is loading the page but the images are not displayed, which is required in my case.
Can anyone explain how to actually open a link in Phonegap.
Well it seems its not possible ..... but I found that we can do it other way round.
We know this works :-
<a data-role="none" id="someID" href="#" target="_blank">
So we can write jQuery as :-
$('#idAnchorTag').attr('href','some URL');
So the complete code is :- (Assuming that click was made on an image)
<a data-role="none" id="idAnchorTag" href="#" target="_blank">
<img id="idIMG" src="some IMAGE">
</a>
And the JS :-
$(function() {
$("#idIMG").click(function(){
$('#idAnchorTag').attr('href','some URL');
});
});
try
$('#pageID').onClick(function(){
document.location.href="http://google.com";
})