【问题标题】:How can I use angular.element instead of jQuery?如何使用 angular.element 而不是 jQuery?
【发布时间】:2020-04-30 10:23:47
【问题描述】:

如何在这段代码中使用angular.element 而不是 jQuery ($)?

<form style="display: none" action="{! $page.FormMigrateDownload}" method="POST" id="jsonDownloadForm">
  <input type="hidden" id="appFormJsonData" name="appFormJsonData" value="" />
  <input type="hidden" id="jsonFileName" name="jsonFileName" value="" />
</form>
$scope.download = function(form) {
  $("#appFormJsonData").val(JSON.stringify(form));
  $("#jsonFileName").val('"TX-' + form.Name + '.json"');
  $("#jsonDownloadForm").submit();
};

【问题讨论】:

    标签: jquery angularjs


    【解决方案1】:

    你可以用喜欢

    > angular.element('#appFormJsonData').val(); OR
    > angular.element('#appFormJsonData')[0].value;
    

    【讨论】:

      【解决方案2】:

      您好,欢迎使用 StackOverflow

      angular.element 只是jQuery(或jqLite,如果您没有安装 jQuery)的包装器,因此您可以像使用 jQuery 一样使用它。

      在 AngularJS 的 API docs 中阅读更多内容

      【讨论】:

        猜你喜欢
        • 2016-07-04
        • 1970-01-01
        • 2013-09-04
        • 2019-11-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-23
        • 1970-01-01
        相关资源
        最近更新 更多