No, it's not dangerous, but you've strained your jaw in some way. Just don't open it sideways -- isn't that obvious? Why would you do something that causes pain when you don't have to? Give it some time to heal.
If it continues, discuss it with a dentist, but in the meantime, just don't do anything to strain it further. Just engage in normal, not "sideways," movement.