st_url is not working properly - angularjs

I am using sharethis in my application.
here is my code
<a style="transition: none;" ng-init="initShare()" class="st_sharethis_custom" ng-if="loggedIn"><i class="fa fa-share-alt" style="/*font-size: 29px;*/"></i><em>SHARE</em></a>
this code works (it gives me the current url and shares)
but now i want to dynamic url so i am adding st_url for my code.
here is the code
<a style="transition: none;" ng-init="initShare()" class="st_sharethis_custom" st_url="#page/{{page.Id}}" ng-if="loggedIn"><i class="fa fa-share-alt" style="/*font-size: 29px;*/"></i><em>SHARE</em></a>
now the problem is the url is taking as "#page/{{page.Id}}" it is not replacing with the base url and with the pageId.
I even tried the full url with pageId (https:/..../page/{{page.Id}})
even this not taking the value of pageId.
can anyone help me with this thanks in advance

Related

How to copy and paste the content in selenium Webdriver?

Can any one please guide me how I can copy content from one site and migrate to other side with the help of selenium WebDriver ?
Just to be clear, you want to perform an copy/paste of the website directory to another folder ?
Or do you want to parse the html contents, and save that in an external file ?
The former is not really selenium friendly.
So an simple example of what you want is this :
Website 1:
<span id="spanID"> content in here </span>
Website 2:
<form id="inputID"> [ you want content in here ] </form>
Please note the pseudo html.
What you need to do in order to make this work is..
browser.get("http://www.website1.com);
var tempElement = $("spanID");
tempElement .getText().then(function (contentOfSpan) {
console.log(contentOfSpan); // will print the content of the span... now you want to save this value somewhere in your scope.
});
/////////////////////////////////////////////////
browser.get("http://www.website2.com);
var tempElement = $("inputID");
tempElement.sendKeys(RefferenceTocontentOfSpan)

Links in strings - Typescript

I'm working at a project written in Ionic/Angular/Typescript. In the .html file, I have
< p> {{stringVar}} </p>
In the .ts file,I have
this.stringVar= "Visit http://www.google.com.
Visit http://www.stackoverflow.com."
I have 2 questions:
1) I want the 2 sentences in the string to be displayed in html on different lines. What should I do in order to achieve this: add \n or < br> or something like this?
2) I want the 2 links in the string to appear as links in html,too. That is,when the user clicks on them,he will be taken to those sites.
Thanks in advance!
1) To appear in different lines, you must put each one inside their own <p> tag, like this:
<p>first line</p>
<p>second line</p>
2) To appear as clickable links, you need to put in <a> tags, with url in href attribute, like this:
<p>click here to visit google.</p>
It would be better if you could change the structure of your data, to something like this:
<p ng-repeat="url in urlList">Visit {{url}}</p>
this.urlList = [
"http://www.google.com",
"http://www.stackoverflow.com"
];
or even better:
<p ng-repeat="site in siteList">Visit {{site.name}}</p>
this.siteList= [
{ name: "Google", url: "http://www.google.com" },
{ name: "StackOverflow", url: "http://www.stackoverflow.com" }
];
The best approach to go with a 'list', rather than a stringVar
this.linkList = [
"http://www.google.com",
"http://www.stackoverflow.com"
];
1) I would suggest to have <p></p> instead of <br/> in between.
2) The following is a working sample with Angular2
<p *ngFor="let link of linkList">Visit {{link}}</p>
Check the working sample here : https://embed.plnkr.co/Om3CXpT9xN07YCz2aHQr/
Both Question has one answer you Basically want to Interpolate string with html in the angular, although i am not expert in angular1.x but yes there is one service used for the same called as
$interpolate(templateString)(you_.ts/js_code);
by using this you can show your string as it as on the webpage event using html in you javascript file too. you just have to pass the html in your string ans display it in the webpage
for example lets assume your use case you simple have to add this like :-
this.stringVar= "Visit <a href='http://www.google.com'>Google</a> Here and<br> Visit <a href='http://www.stackoverflow.com'>Stackoverflow</a> Here."
and than convert this using interpolate like this
$scope.your_string = $interpolate(templateString)(stringVar);
Working Example for the same

Links in drupal blocks are not working

I have created one drupal block containing links which are direct.
Ex:login->user/login
register->user/register
But if i am in user/login link and clicking the link user/register the path is taking as user/user/register.
Please help me in this
Thank you
You need to link to /user/register so your link will be based on home path and not current path.
Or else you can use an absolute path so your link is not dependant of where you are in the site, something like :
<?php
$linkUrl = $base_path . '/user/register';
?>
<a href="<?php print $linkUrl; ?> title="Link to user/register">
https://api.drupal.org/api/drupal/developer!globals.php/global/base_url/7
Use the url function:
$login_url = url('user');
$register_url = url('user/register');

AngularJs: $location.path not working correctly

I am having a weird issue with location.path(),as I don't get redirected to the page I want.
I have a link in my HTML file as follow:
<a title="{{woa.name}}" href="#/" ng-right-click="" href="javascript:void(0)" ng-click="goToDetailPage(woa.pk,'workofart')">
The corresponding controller has the following code:
appTreasure.controller("mySecondController", function($scope, $http, $location) {
$scope.goToDetailPage = function(pk, selectedDetailsPage) {
newLocation = selectedDetailsPage + '/' + pk;
console.log("NEW: " + newLocation);
$location.path(newLocation);
}
// some more unrelated code
The current URL is: <base>/#/beinspiredby and the printed newLocation is something like <base>/#/workofart/someexistingpk. So, I am building the new location with valid values.
Unfortunately, when I click on the link, I get redirected to <base>/#/.
If I manually go to <base>/#/workofart/someexistingpk I correctly land to the page I am looking for.
Furthermore, in a third controller, I have exactly the same code for goToDetailPage and it works.
Where am I missing something?
I think is it because you have an href attribute in your anchor element (actually you have two).
Try this
<a title="{{woa.name}}" ng-right-click="" ng-click="goToDetailPage(woa.pk,'workofart')">

How to $compile the value when using ng-repeat?

<ul class="alert alert-link alert-info"
data-ng-show="messages">
<li data-ng-repeat="msg in messages" data-ng-bind-html="msg | unsafe"></li>
</ul>
The controller code looks as below:
...
var msg = 'You\'re logged in. The registration must ' +
+ 'be <a href="#" ' +
+ 'data-ng-click="logout(\'/ajax/logout/\', $event)">logout</a> of your profile.';
$scope.messages = [msg];
...
How to $compile a msg, if msg comes from the server?
In general it's a really really terrible idea to compile things in angular directly from your backend. You can usually tell that if you're written the word unsafe in your code, you are putting yourself at risk. Not to mention it's going to be hard to find issues with the code if the code is on some other server/model/database somewhere. You should just return a model you can use from your server.
If you must do this, you'll probably want to create a directive which has something like element.html($compile(msg)(scope)) in your link function.

Resources