我正在尝试使用ngHref将href属性绑定到我的链接,但AngularJS会降低它。 我该如何避免这种行为?
<a ng-href="http://preview-{{preview.hash}}.test.com/">{{preview.title}}</a>
它降低了preview.hash,我不想这样做。
答案 0 :(得分:1)
小角度不是角度。这是浏览器。浏览器会缩小URL的域部分中的所有内容。 (输入GOOGLE.COM,然后转到google.com)
看一下这个例子:http://jsbin.com/zupupupo/4/edit?html,js,output
<body ng-app="myApp">
<div ng-controller="MyController">
1. <a ng-href="http://preview-{{preview.hash}}.test.com/">{{preview.title}}</a> Dynamic in the domain
<br />
2. <a ng-href="http://preview.test.com/{{preview.hash}}">{{preview.title}}</a> - Dynamic after domain
</div>
3. <a href="http://preview-TeST.test.com/TeST">Hard Coded Link</a>
</body>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('MyController',function($scope){
$scope.preview = {
hash: 'TeST',
title: 'NG HREF Dynamic Link'
};
});
</script>
如果检查值,则使用来自该值的套管。当您单击/悬停在链接上时,浏览器会将其缩小。 (例1)
保留域部分后的大写字符。 (例2)
为了证明这与angular无关,这是在域中的大写字母和url的域部分之后的硬编码链接。 (例3)