用惯了C#的string.format,在angularjs中还不太习惯字符串的拼接,还好可以自定义String.Format
String.format = function() { if( arguments.length == 0 ) return null; var str = arguments[0]; for(var i=1;i<arguments.length;i++) { var re = new RegExp('\{' + (i-1) + '\}','gm'); str = str.replace(re, arguments[i]); } return str; } var a = "this is {0} test for {1}{2}"; alert(String.format(a, "a","me"."!"));