Below is my angularJS code present in app.js:
'use strict';
var app = angular.module('app', ['slick']);
app.config(['$locationProvider', function($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
}])
app.
controller('messageFunnel',['$scope', '$http',
'$location',function($scope, $http, $location) {
var msgChat = $location.search().msgChat;
var email = $location.search().email;
var url = $location.absUrl();
url = url.substring(0, url.indexOf('msgChat'));
$scope.url = url;
$http({
method: 'POST',
url: 'url',
data: {
"msgChat": msgChat,
"email" : email
}
}).then(function successCallback(response) {
$scope.data = response.data;
console.log($scope.data)
}, function errorCallback(response) {
console.log(response.data);
});
}]);
Below is my html page which basically use the data retrieved from api call in app.js :
<body>
<div class="row" ng-app="app" ng-controller="messageFunnel">
<div class="col-lg-4 col-md-6 col-sm-12">
<div class="white-box">
<h3 class="box-title">Prior</h3>
<div class="comment-center">
<div class="comment-body b-none" ng-repeat="item in data.messages[0].prevArray">
<div class="mail-contnet">
<span class="time">{{item.count}}</span>
<a href="{{scope.url}}msgChat={{item.chat}}" target="_blank"><i class="fa fa-external-link fa-pull-right" aria-hidden="true" style = "font-size:15px;"></i></a>
<br/>
<p>{{item.chat}}</p>
</div>
</div>
</div>
</div>
</div>
I am integrating the angular page as a link in some other jsp page.Below is how i am adding the link in my jsp page in Liferay:
var link = "Current Page URL";
link = link + '&email=' + email+'&msgChat=' + message;//appending parameters to the url
<A href= link target="_blank">Message value</A>
I am integrating the angular page as a embedded link and adding the email and msgChat parameter to that link.But don't know why when I click on the link, my page loads twice once with the parameters and once without the parameters.
PS: I am using liferay and writing the frontend in jsp file.