【问题标题】:How to use template value while calling function?调用函数时如何使用模板值?
【发布时间】:2016-09-30 15:08:51
【问题描述】:

HTML:

<li data-id="{{Name.first}}" ng-click="getNames('{{Name.first}}')">

脚本:

$scope.getNames = function(name) { // I am getting "{{Name.first}}" which I sent. I am not getting the template value
        $http({
            method : "POST",
            url : "/some/url",
            params: { value: id },
            headers: {
                'Content-type': 'application/json'
            }
        }).then(function mySucces(response) {
            $scope.Results = response.data;
        });
    }

请告诉我在调用方法时如何使用模板值?

【问题讨论】:

    标签: jquery html angularjs ajax templates


    【解决方案1】:

    在从 ng-click 指令调用函数时传递范围变量值而不进行插值 ({{}})。

    <li data-id="{{Name.first}}" ng-click="getNames(Name.first)">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-12
      • 2013-06-15
      • 1970-01-01
      • 2011-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多