Nahiduzzaman Rose Nahiduzzaman Rose - 2 months ago 23
AngularJS Question

Why ng-click is unable to send function parameter which is embraced with curly {{ }} 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>