我想通过调用函数来发送路径,将路径作为函数参数发送。
但是我的 Controller 代码:
$scope.go = function(path){
alert(path); //show the path comes in as parameter
$location.path( path );
}
我的 View 代码(.html)
<button ng-click="go('/hotellist/{{topHeading}}?tab=packages')" ></button>
我已经检查了 {{topheading}}
它正确获取了 $scope.topheading
的值,但是当我使用 ng-click< 发送此值时
它根本没有任何值(value)! 警报只是说 '/hotelist/?tab=packages'
。
有什么想法吗?为什么会发生这种情况?
最佳答案
尝试
<button ng-click="go('/hotellist/' + topHeading + '?tab=packages')" ></button>
关于javascript - 为什么 ng-click 无法发送包含在大括号 {{ }} 中的函数参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38432966/