Angular JS - Exposing Controller Function outside the module via onClick function call
Exposing Controller Function outside the module via onClick function call
For re-using already defined onClick functions
HTML
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<div ng-app="myapp" ng-controller="mycontroller">
<table class="friend">
<tr>
<th>Name</th>
<th>Phone</th>
<th>Age</th>
</tr>
<tr ng-repeat="friend in friends | orderBy:'age'">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
<td>{{friend.age}}</td>
</tr>
</table>
</div>
JavaScript
angular.module('myapp', [])
.controller('mycontroller', ['$scope', function($scope) {
$scope.friends =
[{name:'John', phone:'555-1212', age:10},
{name:'Mary', phone:'555-9876', age:19},
{name:'Mike', phone:'555-4321', age:21},
{name:'Adam', phone:'555-5678', age:35},
{name:'Julie', phone:'555-8765', age:29}];
}]);