It works if the minecart it's over a detector rail.
Sorry for not searching first, but I've also discovered that the comparator outputs a signal based on the inventory capacity when the minecart it's over a detector rail. I'm just posting it so people can see.
It works if the minecart it's over a detector rail.