在 AngularJS 中我有一个链接,我需要从范围中插入一个值,我试过这个:
$scope.go = function (path) {
$location.path(path);
};
<a ng-click="go('/edit/{{my.id}}')"><span class="fa fa-pencil-square-o"></span></a>
但这只是传入 /edit/%7B%7Bmy.id%
在模板中这怎么可能?
最佳答案
你试过吗?
$scope.go = function (id) {
$location.path('/edit/'+id);
};
<a ng-click="go(my.id)"><span class="fa fa-pencil-square-o"></span></a>
一些有用的信息:Difference between double and single curly brace in angular JS?
关于javascript - AngularJS 将作用域中的值插入到 ng-click 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20997349/