It is *also* a function of the wattage, as there is a somewhat proportional amount of power that is lost in the motor as heat for any given power input (vs motor characteristics and load and speed, etc.). So if you put 10KW into the motor but at only 10A, if the motor is only 70% efficient at those particular conditions, it's still going to melt it because you have 3KW of heat in there.
But apparently, because of the core losses in laminations, and resistive losses in windings, higher winding currents are more of an immediate problem than the total power input. But winding (phase) currents aren't constant under a given load, like battery current essentially is. They are pulsed with the PWM (for throttle control) and commutation (usually trapezoid on our ebike controllers) steps.
So this makes another issue: depending on the controller design and/or programming, you may have a 20A controller that could still melt the motor down because it's programmed for very high phase currents, so it is sending say (WAG example) 150A pulses down the line. You lose some as heat in resistance of the phase wires getting to the motor, then more as heat in the resistance of the actual windings of the phases, then still more in the laminations because of the changes in current flow as PWM is switched on and off and commutation steps occur to spin the motor, where current flow actually reverses thru any given set of windings for various combinations--that current flow has to slow and stop before reversing, and the magnetic fields in the stator laminations create heat when forming and falling because of eddy currents inside each lamination. Thinner laminations help, up to some point I don't yet understand.
Those core losses, from the laminations, are part of why it gets so much hotter above some certain speed, because after that point it's switching commutation steps fast enough that the eddy currents in the laminations are so high that it makes a lot of waste heat in the process of cancelling them out and changing the field direction, for each step in spinning the motor. So thinner laminations for faster motors, as I understand it, makes them more efficient at those higher speeds (but I am not sure what that does at the lower speeds, as there is always some trade-off).
I'm still just beginning to actually grasp what's going on inside these things, so my explanations might not make sense yet (or even be partly incorrect in detail).