How can I dynamically set links in an angular controller based on a function's result?
<a ng-href="{{ setLink('contact') }}"
Inside the controller:
angular.module("my-app")
.controller('navController', ['$scope', '$document', function($scope, $document) {
$scope.page = $document[0].title;
$scope.home = "My app";
$scope.setLink = function(path) {
return $scope.page == $scope.home ? 'views/' + path : path;
}
}]);
I have been able to hardcode the urls like this:
<a ng-href="{{ page == home ? 'views/contact.html' : 'contact.html' }}"
Is there a way to pass a function as a parameter to ng-href?