Hi, I am trying to open a new page on clicking of a link instead of opening it in the same page.
I am new to angular and unable to achieve.
I need help regarding this.
This is What I have tried so far.
HTML:
<ul ng-controller="ListController">
<li ng-repeat="item in items" ng-controller="ItemController">
<div ng-click="open(item)">{{item.content}}</div>
</li>
<hr>
<ng-switch on="anyItemOpen()">
<div ng-switch-when="true">
<div ng-controller="ItemController">
{{opened.name}}: overlay: tweet, share, pin
</div>
<a ng-click="close()">close</a>
</div>
</ng-switch>
</ul>
JS:
function ItemController($scope) {
}
function ListController($scope) {
$scope.items = [
{name: 'item1', content: 'content1'},
{name: 'item2', content: 'content2'},
{name: 'item3', content: 'content3'}
];
$scope.open = function(item){
if ($scope.isOpen(item)){
$scope.opened = undefined;
} else {
$scope.opened = item;
}
};
$scope.isOpen = function(item){
return $scope.opened === item;
};
$scope.anyItemOpen = function() {
return $scope.opened !== undefined;
};
$scope.close = function() {
$scope.opened = undefined;
};
}
This is My Working Demo