Nahiduzzaman Rose Nahiduzzaman Rose - 3 months ago 10x
AngularJS Question

Why ng-click is unable to send function parameter which is embraced with angular {{ }} brackets?

I want to send a path by calling a function, by sending the path as function parameter.

However my controller code:

$scope.go = function(path){
alert(path); //show the path comes in as parameter
$location.path( path );

My view code (.html)

<button ng-click="go('/hotellist/{{topHeading}}?tab=packages')" ></button>

I have checked
it gets the value of
correctly, but when i am sending this using
it is getting no value at all! The alert is just saying

Any Idea? why this is happening?


Try this,

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope,$location) {
$scope.topHeading = "test";  
$scope.go = function(path){
<script src=""></script>

 <body ng-app="plunker" ng-controller="MainCtrl">
   <button ng-click="go('/hotellist/'+topHeading+'?tab=packages')">GO</button>