2014-06-05 24 views
1

我試圖綁定href屬性到我的鏈接使用ngHref,但AngularJS小寫它。 我該如何避免這種行爲?AngularJS ngHref爲什麼小寫

<a ng-href="http://preview-{{preview.hash}}.test.com/">{{preview.title}}</a> 

它降低了preview.hash,我不想這樣做。

+0

您可以使用大寫/小寫過濾器,如「{{preview.hash | uppercase}}」,但我猜你想保留散列的原始大小,是否正確? –

回答

1

這是不是角度是lowercasing。它是瀏覽器。瀏覽器會降低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)

+0

我希望能夠使用大寫/小寫和base58編碼我的哈希,但它看起來像我不得不使用base32或十六進制,因爲我不能將哈希部分移動到路徑字符串。謝謝,@dmullings – let4be

相關問題