How to disable texture rotation when I rotate an object ?

I’d like to make sure that when I rotate an object, the texture on top doesn’t rotate with it, but I can’t figure out how to do it. Can anyone help?

The red arrow indicates the direction in which the texture is currently facing.
The blue arrow is the direction I want the texture to be in

(The mesh used is the same, they just have a different rotation)

Thanks in advance!

if i understand right
when you rotate the object you can go to modeling mode under UVs while the object is selected and rotate its uv to the side you want