3
當我是相當新的角度和我可能失去了一些東西很明顯,但我有以下的自定義過濾器:角插值誤差數字格式
propertyApp.filter('telLink', function() {
return function(tel) {
// To avoid interpolating error
if(typeof(tel) != undefined) {
// Remove any leading zeros
if(tel.charAt(0) === '0') {
tel = tel.substr(1);
}
tel = "44" + tel;
// Remove any internal whiespace
return tel.replace(" ", "");
}
}
});
當我使用這個視圖中我得到這個:
Can't interpolate: tel:{{property.agent_phone | telLink}}
TypeError: Cannot call method 'charAt' of undefined
有人能指出我在正確的方向?提前致謝。
更好的方法是使用'angular.isDefined(tel)'。它大體上做同樣的事情,但保證價值適合角度消費。 – Soviut