javascript - AngularJS | How to combine ng-dblclick and ng-routing on the same element? -
in app have index.html
there ng-view
directive. inside directive add information main.html
defalut - it's table of names , links. clicking link content of ng-view
updates , information particular link link.html
appears. please, see 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 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 link.html
:
<p>welcome new link {{ id }}</p> <a href="#/">back home</a>
i need able double click same link. question how because adding ng-dblclick
directive doesn't work. there way make possible? i've seen here similar question didn't see answer. thank in advance!
Comments
Post a Comment