小编Aha*_*ack的帖子

Angular HttpClient行为原始HTML

我正在使用Angular 5 HttpClient,并且试图从同时提供json数据和HTML的页面获取HTML响应。(验证身份)。

当我卷曲时,我得到了预期的HTML和json负载。无论我使用HttpClient尝试什么,我所能获得的都是json,在这种情况下这没有帮助。我想获取HTML。我已经验证了我的标头在命令行curl和HttpClient之间完全相同。

curl -vvv https://accounts.spotify.com/authorize/?client_id=xxxxxxxxxxxxxxx81ad8fc&response_type=code&redirect_uri=http://reaver.xxxxxx.com:4200/callback&state=34fFs29kd09

    <!DOCTYPE html>
<html ng-app="accounts" ng-csp>
  <head>
    <meta charset="utf-8">
    <title ng-bind="(title && (title | localize) + ' - ') + 'Spotify'">Spotify</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <base href="/">
    <link href="https://d2d1dxiu3v1f2i.cloudfront.net/a4a5157/css/index.css" media="screen" rel="stylesheet">

    <script async defer src="https://www.google.com/recaptcha/api.js"></script>
    <script async defer src="https://d2d1dxiu3v1f2i.cloudfront.net/a4a5157/js/index.js" sp-bootstrap></script>
    <meta ng-non-bindable sp-bootstrap-data='{"client":{"name":"Playlist Reaver"},"country":"US","useCaptcha":false,"locales":["*"],"BON":["0","0",-795429514]}'>
  </head>
  <body ng-view></body>
</html>
Run Code Online (Sandbox Code Playgroud)

这部分负载就是我可以让HttpClient公开的全部内容。

{"client":{"name":"Playlist Reaver"},"country":"US","useCaptcha":false,"locales":["*"],"BON":["0","0",-795429514]}
Run Code Online (Sandbox Code Playgroud)

通常我会说很棒,但是我确实需要访问HTML。

如何从这样的同时包含json数据和HTML的响应中获取原始html?

我的get呼叫如下所示:

return this.http.get(this.apiGeneric, { params: params, observe: 'response'});
Run Code Online (Sandbox Code Playgroud)

附加信息:我的http标头似乎未添加。我进行了以下更改,并且在HTTP请求标头中没有看到XFF标头。

  // function returns Observable UserResponse object
  getUrl() {
    this.httpHeaders = …
Run Code Online (Sandbox Code Playgroud)

httpclient spotify angular

5
推荐指数
1
解决办法
3785
查看次数

Popover + Angular + Bootstrap 4.3 失败

我正在尝试使用 getbootstrap 站点中的示例代码 popover 元素。

环境:Angular 8.0.0 JQuery 3.4.1 Popper.js 1.15.0 Bootstrap 4.3.1 ToolTip 1.6.1

angular.json 我已经加载了脚本

"scripts": [
  "node_modules/jquery/dist/jquery.min.js",
  "node_modules/popper.js/dist/popper.min.js",
  "node_modules/tooltip/dist/Tooltip.js",
  "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"]
Run Code Online (Sandbox Code Playgroud)

},

样式文件

@import "~bootstrap/dist/css/bootstrap.css";
Run Code Online (Sandbox Code Playgroud)

索引.html

<script>
  $(function () {
    $('[data-toggle="popover"]').popover()
  })
</script>

<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
  Tooltip on top
</button>
<script>
  $(function () {
    $('[data-toggle="popover"]').popover()
  })
</script>
Run Code Online (Sandbox Code Playgroud)

Bootstrap 样式似乎工作正常,但示例工具提示和弹出框不起作用。

即使我用 CDN 方法加载,我似乎也无法让这些工作。 …

popover bootstrap-4 angular

4
推荐指数
1
解决办法
2463
查看次数

标签 统计

angular ×2

bootstrap-4 ×1

httpclient ×1

popover ×1

spotify ×1