在我们的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) 有没有办法在最新的github git gui for mac(desktop.github.com)中设置git diff参数?例如,我希望git-gui忽略diff中的空格变化
git diff --ignore-space-change
Run Code Online (Sandbox Code Playgroud) 在我们的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) 如何重新设置ng-grid的标题?特别是如何更改标题行的背景颜色和文本颜色?
我对ng-include有以下问题.我错过了什么?有人有类似的问题吗?
test.html永远不会包含模板.<h1>Testing</h1> 重复了很多次. Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!我正在做的是一个带有精简版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) angularjs ×4
javascript ×2
css ×1
git ×1
github ×1
http ×1
http-headers ×1
httpresponse ×1
ng-grid ×1
urlencode ×1