Hi there, I'm new to javascript and angularjs. I've created a function in my controller to open a website when clicking on a button. However, I'm encountering an error message saying ReferenceError: openWebsite is not defined when trying to do so. Below is my code. Can someone please help me resolve this issue? Thank you in advance.
Controller:
app.controller('listingdetailController', function ($http, $scope, $compile, $filter, $sce) {
var Catid = '1';
var SearchTxt = 'cay';
var url = encodeURI("http://www.yahoo.com");
$http({
method: 'POST',
url: API_HOST+'/webservice/listingdetail',
headers:
{
'Content-Type': 'application/x-www-form-urlencoded',
'caymanauth': caymanauth
},
data: "&Catid=" + Catid + "&SearchTxt=" + SearchTxt,
contentType: 'application/x-www-form-urlencoded'
}).success(function (data)
{
var i;
var Content = '';
for (i = 0; i<data['Details'].length; i++)
{
if (Content === '')
{
// Your content goes here...
}
else
{
// Your other content goes here...
}
}
$scope.snippet = Content;
}).error(function ()
{
alert("error");
});
$scope.sendEmail = function(email, subject, body){
var link = "mailto:"+ email
+ "&subject=New email " + escape(subject)
+ "&body=" + escape(body);
window.location.href = link;
};
$scope.openWebsite = function ()
{
window.open(url, '_blank', 'location=yes');
};
$scope.trustSnippet = function ()
{
return $sce.trustAsHtml($scope.snippet);
};
});
Now nothing happens when clicking the button. Have any ideas?