javascript - AngularJS 将作用域中的值插入到 ng-click 中

标签 javascript angularjs

在 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/

相关文章:

javascript - 如何获取选中的&lt;input type ="checkbox"/>的值?

c# - 加载并调用包含 javascript 的 html 文件

javascript - 仅将 limitTo 应用于特定的项目组

javascript - 如何在onsen ui 应用程序列表中显示滚动条

javascript - 未启用 CORS 的外部 API 的解决方法?

javascript - Angular JS ng 表错误 TypeError : newParams reload is not a function and 10 digest iterations reached, ABort

javascript - 尝试使用 react-leaflet-choropleth : Cannot read property 'map' of undefined 映射等值线时出错

couchdb - angularjs跨域访问couchdb的方法

angularjs - 如何在 Angular.js 中使用 `$window.history.back()` 返回?

javascript - 来自动态生成文本的工具提示