小编klo*_*ode的帖子

响应头存在于浏览器中但未被Angular $ http response.headers()解析

在我们的Angular应用程序中,我们需要解析一些$ http的响应头.

例如,我们需要解析一些带X前缀的响应头X-Total-Results: 35.

打开Network浏览器开发工具的选项卡并检查相对于$ http请求的资源,我验证了响应头X-Total-Results: 35是否存在.

在浏览器中,X-Total-Results标头可用,但无法在Angular $ http中解析.

有没有办法在$ http中访问'raw'响应并为头文件编写自定义解析器?

$http.({method: 'GET', url: apiUrl,)
    .then( function(response){
        console.log('headers: ', response.headers());
        console.log('results header: ', response.headers('X-Total-Results'));
        // ...
    })
Run Code Online (Sandbox Code Playgroud)

控制台输出

headers: Object {cache-control: "no-cache="set-cookie"", content-type: "application/json;charset=utf-8"}

results header: null
Run Code Online (Sandbox Code Playgroud)

javascript http httpresponse http-headers angularjs

12
推荐指数
1
解决办法
5831
查看次数

如何在Github桌面gui中设置git diff参数

有没有办法在最新的github git gui for mac(desktop.github.com)中设置git diff参数?例如,我希望git-gui忽略diff中的空格变化

git diff --ignore-space-change
Run Code Online (Sandbox Code Playgroud)

git github github-for-mac

8
推荐指数
1
解决办法
1279
查看次数

包含"点"的url查询参数的Angular ui-router

在我们的Angular应用程序中,我们必须处理包含"点"的id.例如:

book = {
  id: '123.456'
}
Run Code Online (Sandbox Code Playgroud)

我们在使用这样的id作为url参数时遇到了问题.如果通过"Angular"进行导航,即点击调用的链接,一切运行良好$state.go('bookDetails', {bookId: book.id});.但重新加载页面时,事情不起作用

"无法获取/bookDetails?bookId=123.456"

在控制器中:

$scope.viewBookDetails = function() {
    $state.go('bookDetails', {bookId: book.id});
}
Run Code Online (Sandbox Code Playgroud)

在视图中

<a href="" ng-click="viewBookDetails(); $event.stopPropagation();">
Run Code Online (Sandbox Code Playgroud)

在路由器中:

.state('bookDetails', {
    url: '/bookDetails?bookId'
}
Run Code Online (Sandbox Code Playgroud)

在浏览器中:

https://example.com/bookDetails?bookId=123.456
Run Code Online (Sandbox Code Playgroud)

如果%2E在浏览器中替换"点",则链接有效.

我们试图在$ state.go()的参数中用"%2E"替换"dot"

$scope.viewBookDetails = function() {
    $state.go('bookDetails', {bookId: book.id.split('.').join('%2E')});
}
Run Code Online (Sandbox Code Playgroud)

但不起作用,因为"%"自动编码,浏览器中的"点"替换为"%252E"

https://example.com/bookDetails?bookId=123%252E456
Run Code Online (Sandbox Code Playgroud)

urlencode query-parameters angularjs angular-ui-router

7
推荐指数
1
解决办法
2519
查看次数

angularjs ng-grid:如何更改标题样式

如何重新设置ng-grid的标题?特别是如何更改标题行的背景颜色和文本颜色?

css angularjs ng-grid

6
推荐指数
1
解决办法
1万
查看次数

ng-include递归地包括整个index.html,并给出错误"10 $ digest()迭代达到"

我对ng-include有以下问题.我错过了什么?有人有类似的问题吗?

  1. test.html永远不会包含模板.
  2. <h1>Testing</h1> 重复了很多次.
  3. 我得到以下内容
    Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
  4. 检查浏览器中的html元素,显示整个index.html由ng-include递归包含.

我正在做的是一个带有精简版index.html的简单测试

的index.html

<html>
  <head>
    <link href="static/bower-components/bootstrap-css/css/bootstrap.min.css" rel="stylesheet">
    <link href="static/src/css/app.css" rel="stylesheet">
    <script src="static/bower-components/angular/angular.js"></script>
    <script src="static/bower-components/angular-route/angular-route.js"></script>
    <script src="static/bower-components/angular-bootstrap/ui-bootstrap-tpls.js"></script> 
    <script src="static/src/js/app.js"></script>
    <script src="static/src/js/services.js"></script>
    <script src="static/src/js/controllers.js"></script>
    <script src="static/src/js/filters.js"></script>
    <script src="static/src/js/directives.js"></script>
  </head>

  <body  ng-app="myApp">
    <h1> Testing </h1>
    <div ng-include="'test.html'"> </div>
  </body>

</html>
Run Code Online (Sandbox Code Playgroud)

的test.html

<h3> included template </h3>
Run Code Online (Sandbox Code Playgroud)

在浏览器中我得到:

测试

测试

....

测试

检查浏览器中的html,显示index.html的递归包含:

<body ng-app="myApp" class="ng-scope">

<h1> Testing </h1>

<!-- ngInclude: 'test.html' --><div ng-include="'test.html'" class="ng-scope">

<link href="static/bower-components/bootstrap-css/css/bootstrap.min.css" rel="stylesheet" class="ng-scope">
<link href="static/src/css/app.css" …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-ng-include

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