Generally you determine angle by using the accelerometer readings. This only works is the unit is not accelerating at the time but you can do a quick sanity check that sqrt(x*x + y *y + z *z) = 1g +/- some error margin. If that is true then you probably aren't accelerating.
For any given axis the amount it is away from pointing straight up will be given by angle = cos-1(reading in g).
If you know how far each axis is from vertical then you can work out your orientation relative to the ground.
If you are accelerating then assuming you knew your orientation before hand you can calculate your current orientation by using the gyro readings to measure the change in orientation. However anything calculated this way will drift away from the correct answer so you will need to correct it once you stop accelerating.
You can use the magnetometer as a sanity check and a method of tracking rotation but it's not very reliable for calculating absolute heading without first being calibrated for your current environment.
All of the readings from an IMU will be very noisy unless you are using a very expensive one, expect to have to average and filter a lot to get smooth results out. In this situation expensive means the price has at least 4 digits before the decimal point.