In my app I have index.html
where there is ng-view
directive. Inside that directive I add information from main.html
as defalut - it's a table of names and links. By clicking a link the content of ng-view
updates and information about the particular link from link.html
appears. Please, see my index.html
:
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head> ... </head>
<body ng-controller="myCtrl">
<h1>AngularJS</h1>
<ng-view></ng-view>
</body>
</html>
My main.js
:
angular
.module('app', ['ngRoute'])
.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'partials/main.html'
})
.when('/link/:id', {
templateUrl: 'partials/circle.html',
controller: 'linkCtrl'
})
.otherwise({
redirectTo: '/'
})
})
.controller('myCtrl', function($scope) {
$scope.obj = [
{name: "aaa", link: "000"},
{name: "bbb", link: "111"},
{name: "ccc", link: "222"}
];
$scope.clickFunc = function() {
alert('Im doubleclicked');
};
})
.controller('linkCtrl', function($scope, $routeParams) {
$scope.id = $scope.obj[$routeParams.id];
});
Here is my main.html
:
<h2>Information</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Link</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="link in obj">
<td>{{ link.name }}</td>
<td><a href="#/link/{{ $index }}" ng-dblclick="clickFunc()">{{ link.link }}</a></td>
</tr>
</tbody>
</table>
And here is link.html
:
<p>Welcome to the new link {{ id }}</p>
<a href="#/">Back to home</a>
I also need to be able to double click the same link. The question is how to do that because adding ng-dblclick
directive doesn't work. Is there any way to make it possible?
I've seen here a similar question but I didn't see the answer.
Thank you for your help in advance!