AngularJS将范围中的值插入ng-click

时间:2014-01-08 13:40:31

标签: 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%

这怎么可能在模板中?

1 个答案:

答案 0 :(得分:2)

你试过这个吗?

$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?