Tag: 开头

Angular JS’Startswith’自定义filter

所以我一直在尝试制作一个自定义filter来搜索’Startswith’参数而不是’Contains’。 我写的每个filter似乎都没有正常工作。 这是我想要实现的一个例子—> http://jsfiddle.net/DMSChris/9ptr9/ function FilterCtrl() { var scope = this; scope.doFilter = function(elem) { if(!scope.searchText) return true; return elem.last_name.toLowerCase().indexOf( scope.searchText.toLowerCase()) == 0; }; } http://jsbin.com/OyubElO/1/edit – 这就是我现在所处的位置。 {{msg.last_name}} 任何帮助将不胜感激!